[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Selecting node at a certain position from a nodeset
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|