This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: Indexing in xsl
- From: "Andrew Welch" <awelch at piper-group dot com>
- To: <xsl-list at lists dot mulberrytech dot com>
- Date: Thu, 21 Feb 2002 13:58:27 -0000
- Subject: RE: [xsl] Indexing in xsl
- Reply-to: xsl-list at lists dot mulberrytech dot com
><orders order1-id="1" order2-id="2" order2-id="3" order2-id="4" />
Well, if you meant:
<orders order1-id="1" order2-id="2" order3-id="3" order4-id="4" />
Then you could use:
<xsl:template match="orders">
<xsl:copy>
<xsl:for-each select="order">
<xsl:attribute name="{concat(local-name(), position(), '-','id')}">
<xsl:value-of select="@id"/>
</xsl:attribute>
</xsl:for-each>
</xsl:copy>
</xsl:template>
You were nearly right, you just needed to use position() instead of a var to
get the incrementing value.
cheers
andrew
===
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.325 / Virus Database: 182 - Release Date: 2/19/02
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list