xsl-list
[Top] [All Lists]

RE: knowing the position of certain node

2004-01-06 07:35:54
Thanks George and David for your answer... it worked :-)

-----Mensaje original-----
De: owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
[mailto:owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com]En nombre de 
George
Cristian Bina
Enviado el: Martes, 06 de Enero de 2004 9:21
Para: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Asunto: Re: [xsl] knowing the position of certain node


You can just count the element on the preceding-sibling axis and add 1 to
that, for instance:
<xsl:value-of select="1 + count(row[field2='yes']/preceding-sibling::*)"/>

Best Regards,
 George
-------------------------------------------------------------
George Cristian Bina mailto:george(_at_)oxygenxml(_dot_)com
<oXygen/> XML Editor - http://www.oxygenxml.com/

----- Original Message -----
From: "Jaime A Stuardo Bahamondes" <jstuardo(_at_)security(_dot_)cl>
To: <xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>
Sent: Tuesday, January 06, 2004 3:50 PM
Subject: [xsl] knowing the position of certain node


Hi all..

I have this sample XML:

<test>
  <row>
    <field1>this</field1>
  </row>
  <row>
    <field1>is</field1>
  </row>
  <row>
    <field1>a</field1>
    <field2>yes</field2>
  </row>
  <row>
    <field1>test</field1>
  </row>
</test>


If I use <xsl:value-of select="row[field2 = 'yes']" /> I get all the third
"row" field values. How can I know the position of the found node? for
example, in that case, I want 3 to be printed on screen, something like
"position(row[field2 = 'yes'])"

Thanks
Jaime

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



<Prev in Thread] Current Thread [Next in Thread>