File: Data.xml
<?xml version="1.0"?>
<shopping-list>
<item>bananas</item>
<item>apples</item>
<special-item>item special</special-item>
<item>grapes</item>
<special-item>item 2</special-item>
<item>cherries</item>
</shopping-list>
File: Transform.xslt
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="item | special-item">
<xsl:number count="item | special-item" />
<xsl:text> </xsl:text>
<xsl:value-of select="." />
<br />
</xsl:template>
</xsl:stylesheet>
Output:
<?xml version="1.0" encoding="UTF-8"?>
1 bananas<br/>
2 apples<br/>
3 item special<br/>
4 grapes<br/>
5 item 2<br/>
6 cherries<br/>
|