File: Data.xml
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="Transform.xslt" type="text/xsl"?>
<member>
<state joined="1995">Austria</state>
<state joined="1950">Belgium</state>
<state joined="1973">Denmark</state>
<state joined="1995">Finland</state>
<state joined="1950">France</state>
</member>
File: Transform.xslt
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" />
<xsl:template match="member">
<xsl:text>Number of EU Member States: </xsl:text>
<xsl:value-of select="count(state)" />
<xsl:text> </xsl:text>
<xsl:apply-templates select="state/@joined">
<xsl:sort data-type="number" />
</xsl:apply-templates>
<xsl:text> </xsl:text>
</xsl:template>
<xsl:template match="state/@joined">
<xsl:text> - </xsl:text>
<xsl:apply-templates select=".." />
<xsl:text> (</xsl:text>
<xsl:value-of select="." />
<xsl:text>) </xsl:text>
</xsl:template>
</xsl:stylesheet>
Output:
Number of EU Member States: 5
- Belgium (1950)
- France (1950)
- Denmark (1973)
- Austria (1995)
- Finland (1995)
|