[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Capturing position as a number
Charles Flanders wrote:
I need to capture an elements position as an integer to a variable so I can use that number in capture the text from another element that shares the same position number in another part of the tree. Well position() depends on how you process the 'CONDITION' elements for instance if you have <xsl:template match="Document"> <xsl:apply-templates select="CONDITION"/> <xsl:template> then in your template matching CONDITION for the first such element in your sample document position() will return 1, for the second it will return 2. So you could store <xsl:variable name="pos" select="position()"/> Your variable CurrentCond does not make much sense to me as you are trying to access a CONDITION child element inside the template for CONDITION elements and in your XML sample your CONDITION elements do not have any children of the same name. If you don't want to depend on the position() function and the way nodes are processed to count nodes then look into the count function or look into xsl:number e.g. <xsl:variable name="pos"> <xsl:number/> <xsl:variable> -- Martin Honnen http://JavaScript.FAQTs.com/
|
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
|