<xforms:repeat> and indexing

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

<xforms:repeat> and indexing

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

Re: <xforms:repeat> and indexing

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

Re: <xforms:repeat> and indexing

ToddG
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,

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





--
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 indexing

David McIntyre
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
 
 
 
Dave McIntyre
Software Developer
2nd Floor, Orion House, cnr Enfield & Mary St, Mt Eden, PO Box 8273, Auckland, New Zealand
M.+64 21 212 8087 P.+64 9 638 0600 F.+64 9 638 0699
S.<A href="callto:dave.mcintyre">dave.mcintyre E.[hidden email] W.www.orionhealth.com
This e-mail and any attachments are intended only for the person to whom it is addressed and may contain privileged, proprietary, or other data protected from disclosure under applicable law. If you are not the addressee or the person responsible for delivering this to the addressee you are hereby notified that reading, copying or distributing this transmission is prohibited. If you have received this e-mail in error, please telephone us immediately and remove all copies of it from your system. Thank you for your co-operation.


>>> "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,

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





--
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 indexing

ToddG
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:
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
 
 
 
Dave McIntyre
Software Developer
2nd Floor, Orion House, cnr Enfield & Mary St, Mt Eden, PO Box 8273, Auckland, New Zealand
M.+64 21 212 8087 P.+64 9 638 0600 F.+64 9 638 0699
S.dave.mcintyre E.[hidden email] W.<a onclick="return top.js.OpenExtLink(window,event,this)" href="http://www.orionhealth.com/" target="_blank">www.orionhealth.com
This e-mail and any attachments are intended only for the person to whom it is addressed and may contain privileged, proprietary, or other data protected from disclosure under applicable law. If you are not the addressee or the person responsible for delivering this to the addressee you are hereby notified that reading, copying or distributing this transmission is prohibited. If you have received this e-mail in error, please telephone us immediately and remove all copies of it from your system. Thank you for your co-operation.


>>> "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,

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: <a onclick="return top.js.OpenExtLink(window,event,this)" href="http://www.objectweb.org/wws" target="_blank">http://www.objectweb.org/wws
>
>
>


--
Blog (XML, Web apps, Open Source):
<a onclick="return top.js.OpenExtLink(window,event,this)" href="http://www.orbeon.com/blog/" target="_blank">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: <a onclick="return top.js.OpenExtLink(window,event,this)" href="http://www.objectweb.org/wws" target="_blank">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: <a onclick="return top.js.OpenExtLink(window,event,this)" href="http://www.objectweb.org/wws" target="_blank"> 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: <xforms:repeat> and indexing

raul.aguilar
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


Alessandro Vernet wrote
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 <todd.gochenour@gmail.com> 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 ops-users@objectweb.org
> mailing list.
> To unsubscribe: mailto:ops-users-unsubscribe@objectweb.org
> For general help: mailto:sympa@objectweb.org?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 ops-users@objectweb.org mailing list.
To unsubscribe: mailto:ops-users-unsubscribe@objectweb.org
For general help: mailto:sympa@objectweb.org?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws