nested repeat by reference

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

nested repeat by reference

Teun van Eijsden
If i have xml data like this:
 
<root>
   <refs>
      <ref id="r1" title"Banana"/>
      <ref id="r2" title"Apple"/>
   </refs>
   <values>
      <value refid="r1">1</value>
      <value refid="r1">34</value>
      <value refid="r2">234</value>
  </values>
</root>
 
and i want a nested repeat like this:
 
<xforms:repeat nodeset="/rootrefs/ref" id="ref-repeat">
    <xforms:repeat nodeset="/root/values/value[@refid=index('ref-repeat')]" id="ref-repeat">
    </xforms:repeat>
</xforms:repeat>
This doesn't work. The index('ref-repeat') does not hold the value i expect, but always returns 1.
How do i do this?
 
Teun

-- The information contained in this communication and any attachments is confidential and may be privileged, and is for the sole use of the intended recipient(s). Any unauthorized review, use, disclosure or distribution is prohibited. Unless explicitly stated otherwise in the body of this communication or the attachment thereto (if any), the information is provided on an AS-IS basis without any express or implied warranties or liabilities. To the extent you are relying on this information, you are doing so at your own risk. If you are not the intended recipient, please notify the sender immediately by replying to this message and destroy all copies of this message and any attachments. ASML is neither liable for the proper and complete transmission of the information contained in this communication, nor for any delay in its receipt.

--
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
Reply | Threaded
Open this post in threaded view
|

Re: nested repeat by reference

Erik Bruchez
Administrator
Teun,

> If i have xml data like this:
>  
> <root>
>    <refs>
>       <ref id="r1" title"Banana"/>
>       <ref id="r2" title"Apple"/>
>    </refs>
>    <values>
>       <value refid="r1">1</value>
>       <value refid="r1">34</value>
>       <value refid="r2">234</value>
>   </values>
> </root>
>  
> and i want a nested repeat like this:
>  
> <xforms:repeat nodeset="/rootrefs/ref" id="ref-repeat">
>     <xforms:repeat
> nodeset="/root/values/value[@refid=index('ref-repeat')]" id="ref-repeat">
>     </xforms:repeat>
> </xforms:repeat>
> This doesn't work. The index('ref-repeat') does not hold the value i
> expect, but always returns 1.
> How do i do this?
You may want to try the xxforms:repeat-current() function:

<xforms:repeat nodeset="/root/refs/ref" id="ref-repeat">
     <xforms:repeat
       nodeset="/root/values/value[@refid
         = xxforms:repeat-current('ref-repeat')/@id]"
       id="ref-repeat">
   </xforms:repeat>
</xforms:repeat>

The index() function returns the repeat index, which is the index of the
iteration currently selected in the UI.

This use case should be solved better in the future with variables.

-Erik

--
Orbeon Forms - Web Forms for the Enterprise Done the Right Way
http://www.orbeon.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