[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: position of an element
-----Ursprüngliche Nachricht----- Von: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]Im Auftrag von Michael Kay Gesendet: Freitag, 25. Mai 2001 14:16 An: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Betreff: RE: position of an element >> <template match="content"> >> <xsl:value-of >> select="position-of-this-element-in-the-document()" /> >> </template> >> > You can use xsl:number, or count(preceding-sibling::*)+1 Ok, xsl:number works for the little example I gave above, but in fact my XML looks like this: --- snip -- <xmltable> <row> <data><content key="string"></data> <data><content key="image"></data> <data><content key="string"></data> </row> <row> <data> <xmltable> <row> <data><content key="image"></data> <data><content key="image"></data> <data><content key="string"></data> </row> <xmltable> </data> </row> </xmltable> --- snip --- That means if I wanted to count/number the content elements, <xsl:number level="any" /> would output the correct result. Now I want to count the content elements with key="string", then the ones with key="image" etc. I could make a <xsl:template match="content[@key = 'string']> and then <xsl:number as shown above and it would work as well. But I want <xsl:template match="content">, not specified with the key attribute value. Inside this template I need the number/count of the content elements with the specific key attribute values, for example: "This is the third content element with key=string in the document." "This is the fifth content element with key=image in the document." Thanks Sebastian Schirmer 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
|