File: Data.xml
<?xml version="1.0" encoding="iso-8859-1"?>
<itinerary>
<day number="1">day 1</day>
<day number="2">day 2</day>
<day number="3">day 3</day>
<day number="4">day 4</day>
<day number="5">day 5</day>
<day number="6">day 6</day>
<day number="7">day 7</day>
<day number="8">day 8</day>
<day number="9">day 9</day>
</itinerary>
File: Transform.xslt
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xsl:import href="itinerary.xsl" />
<xsl:param name="highlight-day" as="xs:integer" required="yes" />
<xsl:key name="day-number" match="day" use="xs:integer(@number)" />
<xsl:template match="key('day-number', $highlight-day)//text()">
<font color="red">
<xsl:value-of select="." />
</font>
</xsl:template>
</xsl:stylesheet>
File: itinerary.xsl
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<head>
<title>Itinerary</title>
</head>
<body>
<center>
<xsl:apply-templates select="//day" />
</center>
</body>
</html>
</xsl:template>
<xsl:template match="day">
<h3>
Day
<xsl:value-of select="@number" />
</h3>
<p>
<xsl:apply-templates />
</p>
</xsl:template>
</xsl:stylesheet>
|