xforms:repeat and flat hierarchy

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

xforms:repeat and flat hierarchy

fl.schmitt
Hi,

i'm just starting to work with OPS / Forms and got a little problem implementing xforms:repeat. My instance XML File looks like follows:

<parent>
    <child1 />
    <child2 /> <!-- Repeatable Element -->
</parent>

Example with data:
<parent>
    <child1>foo</child1>
    <child2>bar</child2>
    <child2>another</child2>
</parent>

The child2 Element may be repeated, but without a surrounding, grouping element that could be referenced in the nodeset Attribute of xforms:repeat (so i called that a "flat hierarchy"). I can't change the XML Schema to introduce a new parent2 for child2. Is there a way to address all the child2 elements in a xforms:repeat?

I tried:

<xhtml:ul>
    <xforms:repeat nodeset="instance('main-instance')/child2">
        <xhtml:li>
             <xforms:output ref="../child2"/>
        </xhtml:li>
    </xforms:repeat>
</xhtml:ul>

But i get:
- bar
- bar

I think i have to address the _actual_ context node in the ref XPath clause, not
'hardcoded' as in my try pointing always at the first child2 node, but i don't know how.

Any help is appreciated.



--
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
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

RE: xforms:repeat and flat hierarchy

Ryan Puddephatt
Florian,
        What is it your trying to achieve, if you want to repeat all the
child2 nodes, then change the ref of your output to "." and it will output

- bar
- another

Ryan

Ryan Puddephatt
Software Engineer

Teleflex Group - IT UK
1 Michaelson Square
Livingston
West Lothian
Scotland
EH54 7DP

e> [hidden email]
t> +44(0)1506 407 110
f> +44(0)1506 407 108

 

>-----Original Message-----
>From: [hidden email] [mailto:[hidden email]]
>Sent: 15 November 2006 10:53
>To: [hidden email]
>Subject: [ops-users] xforms:repeat and flat hierarchy
>
>Hi,
>
>i'm just starting to work with OPS / Forms and got a little
>problem implementing xforms:repeat. My instance XML File looks
>like follows:
>
><parent>
>    <child1 />
>    <child2 /> <!-- Repeatable Element --> </parent>
>
>Example with data:
><parent>
>    <child1>foo</child1>
>    <child2>bar</child2>
>    <child2>another</child2>
></parent>
>
>The child2 Element may be repeated, but without a surrounding,
>grouping element that could be referenced in the nodeset
>Attribute of xforms:repeat (so i called that a "flat
>hierarchy"). I can't change the XML Schema to introduce a new
>parent2 for child2. Is there a way to address all the child2
>elements in a xforms:repeat?
>
>I tried:
>
><xhtml:ul>
>    <xforms:repeat nodeset="instance('main-instance')/child2">
>        <xhtml:li>
>             <xforms:output ref="../child2"/>
>        </xhtml:li>
>    </xforms:repeat>
></xhtml:ul>
>
>But i get:
>- bar
>- bar
>
>I think i have to address the _actual_ context node in the ref
>XPath clause, not 'hardcoded' as in my try pointing always at
>the first child2 node, but i don't know how.
>
>Any help is appreciated.
>
>



--
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
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: xforms:repeat and flat hierarchy

Henrik Pettersen
In reply to this post by fl.schmitt
Florian,

actually, nodeset="instance('main-instance')/child2" selects all
<child2> elements. All you have to do next is iterate over them:

<xhtml:ul>
    <xforms:repeat nodeset="instance('main -instance')/child2">
         <xhtml:li>
              <xforms:output ref="."/>
         </xhtml:li>
     </xforms:repeat>
</xhtml:ul>

Note the use of '.' to address the current node or element.

"../child2" actually says "Go up one level to the parent element, then
select the first child element named 'Child2'", and is equivalent to
"../child2[1]".

Hope that helps.

Henrik


On 11/15/06, [hidden email] <[hidden email]> wrote:

> Hi,
>
> i'm just starting to work with OPS / Forms and got a little problem implementing xforms:repeat. My instance XML File looks like follows:
>
> <parent>
>     <child1 />
>     <child2 /> <!-- Repeatable Element -->
> </parent>
>
> Example with data:
> <parent>
>     <child1>foo</child1>
>     <child2>bar</child2>
>     <child2>another</child2>
> </parent>
>
> The child2 Element may be repeated, but without a surrounding, grouping element that could be referenced in the nodeset Attribute of xforms:repeat (so i called that a "flat hierarchy"). I can't change the XML Schema to introduce a new parent2 for child2. Is there a way to address all the child2 elements in a xforms:repeat?
>
> I tried:
>
> <xhtml:ul>
>     <xforms:repeat nodeset="instance('main-instance')/child2">
>         <xhtml:li>
>              <xforms:output ref="../child2"/>
>         </xhtml:li>
>     </xforms:repeat>
> </xhtml:ul>
>
> But i get:
> - bar
> - bar
>
> I think i have to address the _actual_ context node in the ref XPath clause, not
> 'hardcoded' as in my try pointing always at the first child2 node, but i don't know how.
>
> Any help is appreciated.
>
>
>
>
> --
> 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
> ObjectWeb mailing lists service home page: http://www.objectweb.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
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: RE: xforms:repeat and flat hierarchy

fl.schmitt
In reply to this post by Ryan Puddephatt
Hi Ryan,

thank you very much for the quick help, now it works fine :-)
-------- Original-Nachricht --------
Datum: Wed, 15 Nov 2006 11:12:09 +0000
Von: Ryan Puddephatt <[hidden email]>
An: [hidden email]
Betreff: RE: [ops-users] xforms:repeat and flat hierarchy

> Florian,
> What is it your trying to achieve, if you want to repeat all the
> child2 nodes, then change the ref of your output to "." and it will output
>
> - bar
> - another
>
> Ryan

--
http://www.florian-schmitt.net




--
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
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws