|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: displaying position of nodes
[Mac Martine] > I'm trying to loop through all the nodes and display the > position of the node next to the value of the node. The > values display, but only one of the positions displays. Why > is that??? Because your template is only getting called once - on the document element (/). You are getting the "string value" of the root element (the first child of the document element), and displaying its position() value, which is 1. If you want to get more (but unknown) levels of nested elements you need to use some kind of recursion. You may be thinking of something like this - <xsl:template match="*"> <xsl:value-of select="name()"/> (<xsl:value-of select='text()'/>) ==<xsl:value-of select="position()"/>== <br/> <xsl:apply-templates select='*'/> </xsl:template> I put in the "<br/>" element just to get a more readable display in Internet Explorer - tinker with the format as you like. Notice that position() gives you the position of an element relative to the top of the subtree it is in when matched by a template, and not necessarily the element count as you might have been expecting. Cheers, Tom P 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
|

Cart








