Iterating through a series of <log> elements, I want to render the first one differently than the rest. I have code that looks like:
<xforms:repeat nodeset="log" id="log">
<xforms:group ref=".[position()>1]"> <xforms:group ref=".[by!='']"> <xforms:output ref="by"/> </xforms:group> </xforms:group> <xforms:group ref=".[position()=1]"> <xforms:input ref="by" class="task-description-input"> <xforms:label>User </xforms:label> </xforms:input> </xforms:group> </xforms:repeat> When it renders, the second group (the input, not the output) is used in all cases. Ideas?
Todd
-- 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 |
Administrator
|
Todd,
The value of position() in this case is always 1. Instead you can use: <xforms:group ref=".[empty(preceding-sibling::log)]"> This will run only on the first log <xforms:group ref=".[exists(preceding-sibling::log)]"> This will run on all but the first log Alex On 11/14/06, Todd Gochenour <[hidden email]> wrote: > Iterating through a series of <log> elements, I want to render the first one > differently than the rest. I have code that looks like: > > <xforms:repeat nodeset="log" id="log"> > <xforms:group ref=".[position()>1]"> > <xforms:group ref=".[by!='']"> > <xforms:output ref="by"/> > </xforms:group> > </xforms:group> > <xforms:group ref=".[position()=1]"> > <xforms:input ref="by" class="task-description-input"> > <xforms:label>User </xforms:label> > </xforms:input> > </xforms:group> > </xforms:repeat> > > When it renders, the second group (the input, not the output) is used in all > cases. Ideas? > > Todd > > -- > 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 > > > -- Blog (XML, Web apps, Open Source): http://www.orbeon.com/blog/ -- 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
--
Follow Orbeon on Twitter: @orbeon Follow me on Twitter: @avernet |
If the value of position() is always 1, then how can there be a preceding-sibling?
On 11/14/06, Alessandro Vernet <[hidden email]> wrote:
Todd, -- 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 |
I hope I can explain this: it's clear in my own mind but a little tricky to put into words.
The reason that position() is always 1 in the case you had is that the meaning of position() is always in the current context, whatever that may be.
When you write <xforms:group ref=".[position()=1]">, the "." becomes the current context for the [position()=1] predicate, which means that it looks at the position of the current element among the list ".". This list has only one element in it, which is why the position is 1.
On the other hand, the preceding-sibling:: axis isn't restricted to the current context so it can "see" the previous elements.
HTH,
Dave McIntyre
>>> "Todd Gochenour" <[hidden email]> 16/11/2006 9:30 a.m. >>> If the value of position() is always 1, then how can there be a preceding-sibling? On 11/14/06, Alessandro Vernet <[hidden email]> wrote:
Todd, -- 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 |
Oh, I get it. The contents of '.' is just the current node, therefore only 1 item. Thanks for the explanation.
Todd
On 11/15/06, David McIntyre <[hidden email]> wrote:
-- 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 |
In reply to this post by Alessandro Vernet
Alessandro,
had same question and found your response. though did find the need to change the repeat id 'log' to simply an asterisk '*' (was a hack without the understanding) so that this example code works: <xforms:group ref=".[empty(preceding-sibling::*)]"> <xforms:output value="isfirst"/>isfirst<br/> </xforms:group> <xforms:group ref=".[exists(preceding-sibling::*)]"> <xforms:output value="isafterfirst"/>isafterfirst<br/> </xforms:group> Raul Global Institute for Sustainability Arizona State University
|
Free forum by Nabble | Edit this page |