[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
[xsl] Selecting node at a certain position from a nodeset
Subject: [xsl] Selecting node at a certain position from a nodeset From: Marco Guazzone <sguazt@xxxxxxxxxxx> Date: Wed, 22 Jan 2003 14:06:12 +0100 (CET) |
Hi, I want to select node at position $pos (e.g. $pos = number('1')) from a nodeset; here below are the XML-XSL sheets with which I have to work. Inside template "/doc" there are three "apply-templates" instructions: * the 1st selects all nodes satisfying the xpath conditions (this is showed only for debugging purpose) * the 2nd should select node at position $pos; instead it doesn't work!! Why??!?!?!!? * the 3rd select node at position $pos and works!!! So why doesn't the 2nd one work? Anyone has a better solution? Thanks in advance! XML: <?xml version="1.0"?> <doc> <sections> <section id="1" group="1"> <item id="1">item1-section1</item> <item id="2">item2-section1</item> </section> <section id="2" group="2"> <item id="1">item1-section2</item> <item id="2">item2-section2</item> </section> <section id="3" group="3"> <item id="1">item1-section3</item> <item id="2">item2-section3</item> </section> <section id="4" group="1"> <item id="1">item1-section4</item> <item id="2">item2-section4</item> </section> <section id="5" group="1"> <item id="1">item1-section5</item> <item id="2">item2-section5</item> </section> </sections> </doc> XSL: <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:exsl="http://exslt.org/common" > <xsl:variable name="sections" select="/doc/sections"/> <xsl:variable name="pos" select="1"/> <xsl:template match="/doc"> <xsl:apply-templates select="$sections/section[@group=1]/item[@id=1]"/> <xsl:text>
</xsl:text> <xsl:apply-templates select="$sections/section[@group=1]/item[@id=1][$pos]"/> <xsl:text>
</xsl:text> <xsl:apply-templates select="exsl:node-set($sections/section[@group=1]/item[@id=1])[$pos]"/> </xsl:template> <xsl:template match="item"> <xsl:apply-templates/> <xsl:text> </xsl:text> </xsl:template> </xsl:stylesheet> ------------------------------- Marco Guazzone Software Engineer Kerbero S.r.L. - Gruppo TC Viale Forlanini, 36 Garbagnate M.se (MI) 20024 - Italy mail: marco.guazzone@xxxxxxxxxxx www: http://www.kerbero.com Tel. +39 02 99514.247 Fax. +39 02 99514.399 -------------------------------- XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] xsl pipeline?, cknell | Thread | Re: [xsl] Selecting node at a certa, David Carlisle |
Re: [xsl] Selecting node at a certa, Oleg Tkachenko | Date | Re: [xsl] Selecting node at a certa, David Carlisle |
Month |
Keywords