File: Data.xml
<?xml version="1.0"?>
<mammals locale="North America">
<mammal junk="yyy">A</mammal>
<mammal>B</mammal>
<mammal>C</mammal>
<mammal>D</mammal>
<mammal>E</mammal>
<mammal>F</mammal>
<mammal>G</mammal>
</mammals>
File: Transform.xslt
<?xml version="1.0" encoding="US-ASCII"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes" />
<xsl:template match="mammals">
<north.american>
<mammal>
<cat>
<xsl:apply-templates select="mammal[6]" />
</cat>
</mammal>
</north.american>
</xsl:template>
</xsl:stylesheet>
Output:
<?xml version="1.0" encoding="UTF-8"?>
<north.american>
<mammal>
<cat>F</cat>
</mammal>
</north.american>
|