File: Data.xml
<?xml version="1.0"?>
<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="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>
Output:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Itinerary</title>
</head>
<body>
<center>
<h3>
Day
1
</h3>
<p>day 1</p>
<h3>
Day
2
</h3>
<p>day 2</p>
<h3>
Day
3
</h3>
<p>day 3</p>
<h3>
Day
4
</h3>
<p>day 4</p>
<h3>
Day
5
</h3>
<p>day 5</p>
<h3>
Day
6
</h3>
<p>day 6</p>
<h3>
Day
7
</h3>
<p>day 7</p>
<h3>
Day
8
</h3>
<p>day 8</p>
<h3>
Day
9
</h3>
<p>day 9</p>
</center>
</body>
</html>
|