Question in linking 2 instance using xpath

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Question in linking 2 instance using xpath

quinquin2209
Hi,

I have 2 XML instances, one is books information, and another is about the modification on some of the book:

<books>
   <book>
       <name>ABC</name>
       <price>15</price>
   </book>
   <book>
       <name>DEF</name>
       <price modifyId="1">18</price>
   </book>
   <book>
       <name>ABC</name>
       <price modifyId="2">20</price>
   </book>
</books>

<modifications>
   <modification>
      <id>1</id>
      <oldValue>88</oldValue>
   </modification>
   <modification>
      <id>2</id>
      <oldValue>120</oldValue>
   </modification>
</modifications>

In the xform, I wanna display the book information, plus the modification, if any. The way to link between these 2 instances is to use the modifyId mapping to the /modifications/modification/id.

I have written the form as follow:

<xforms:repeat context="instance('books-instance')" nodeset="//book" id="book-repeat">
        <xforms:input  ref="name"></xforms:input>
        <xforms:input  ref="price"></xforms:input>
</xforms:repeat>

However, i have no idea on how can I linkup the book info with the modifications using the xpath.

Any suggestion on how I can achieve it?

Thanks in advance

Queenie
Reply | Threaded
Open this post in threaded view
|

Re: Question in linking 2 instance using xpath

Alexander Žaťko
I think you can use the xxforms:repeat-current function.

<xforms:repeat context="instance('books-instance')" nodeset="//book"  
id="book-repeat">
     <xforms:input  ref="name"/>
     <xforms:input  ref="price"/>
     <xforms:repeat nodeset="instance('modifications')/modification[id  
= xxforms:repeat-current('book-repeat')/price[@modifyId]/@modifyId"  
id="book-mods">
         <xforms:output ref="price"/>
     </xforms:repeat>
</xforms:repeat>

See http://www.orbeon.com/ops/doc/reference-xforms-2 for more info.

A.

On Feb 11, 2008, at 3:17 AM, quinquin2209 wrote:

>
> Hi,
>
> I have 2 XML instances, one is books information, and another is  
> about the
> modification on some of the book:
>
> <books>
>   <book>
>       <name>ABC</name>
>       <price>15</price>
>   </book>
>   <book>
>       <name>DEF</name>
>       <price modifyId="1">18</price>
>   </book>
>   <book>
>       <name>ABC</name>
>       <price modifyId="2">20</price>
>   </book>
> </books>
>
> <modifications>
>   <modification>
>      <id>1</id>
>      <oldValue>88</oldValue>
>   </modification>
>   <modification>
>      <id>2</id>
>      <oldValue>120</oldValue>
>   </modification>
> </modifications>
>
> In the xform, I wanna display the book information, plus the  
> modification,
> if any. The way to link between these 2 instances is to use the  
> modifyId
> mapping to the /modifications/modification/id.
>
> I have written the form as follow:
>
> <xforms:repeat context="instance('books-instance')" nodeset="//book"
> id="book-repeat">
> <xforms:input  ref="name"></xforms:input>
> <xforms:input  ref="price"></xforms:input>
> </xforms:repeat>
>
> However, i have no idea on how can I linkup the book info with the
> modifications using the xpath.
>
> Any suggestion on how I can achieve it?
>
> Thanks in advance
>
> Queenie
> --
> View this message in context: http://www.nabble.com/Question-in-linking-2-instance-using-xpath-tp15404466p15404466.html
> Sent from the ObjectWeb OPS - Users mailing list archive at  
> Nabble.com.
>
>
> --
> You receive this message as a subscriber of the [hidden email]  
> mailing list.
> To unsubscribe: mailto:[hidden email]
> For general help: mailto:[hidden email]?subject=help
> OW2 mailing lists service home page: http://www.ow2.org/wws


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws