This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: position of an element
- To: "'xsl-list at lists dot mulberrytech dot com'" <xsl-list at lists dot mulberrytech dot com>
- Subject: RE: [xsl] position of an element
- From: Sebastian Schirmer <schirmer at sitewaerts dot de>
- Date: Fri, 25 May 2001 17:50:10 +0200
- Reply-To: xsl-list at lists dot mulberrytech dot com
-----Ursprüngliche Nachricht-----
Von: owner-xsl-list@lists.mulberrytech.com
[mailto:owner-xsl-list@lists.mulberrytech.com]Im Auftrag von Michael Kay
Gesendet: Freitag, 25. Mai 2001 14:16
An: xsl-list@lists.mulberrytech.com
Betreff: RE: [xsl] 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