XML Code
|
<?xml version="1.0" encoding="UTF-8"?>
<catalog>
<cd>
<title>Empire
Burlesque</title>
<artist>Bob
Dylan</artist>
<country>USA</country>
<company>Columbia</company>
<price>10.90</price>
<year>1985</year>
</cd>
<cd>
<title>Hide
your heart</title>
<artist>Bonnie
Tyler</artist>
<country>UK</country>
<company>CBS
Records</company>
<price>9.90</price>
<year>1988</year>
</cd>
</catalog>
|
Before XSLT
|
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h2>My CD
Collection</h2>
<table
border="1">
<tr
bgcolor="#9acd32">
<th>Title</th>
<th>Artist</th>
</tr>
<tr>
<td><xsl:value-of
select="catalog/cd/title"/></td>
<td><xsl:value-of
select="catalog/cd/artist"/></td>
</tr>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
|
Added below marked lines of code
|
|
After XSLT
|
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:variable
name="smallcase" select="'abcdefghijklmnopqrstuvwxyz'"
/>
<xsl:variable
name="uppercase" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"
/>
<html>
<body>
<h2>My CD
Collection</h2>
<table
border="1">
<tr
bgcolor="#9acd32">
<th>Title</th>
<th>Artist</th>
</tr>
<tr>
<td><xsl:value-of
select="catalog/cd/title"/></td>
<td><xsl:value-of
select="catalog/cd/artist"/></td>
<td><xsl:value-of
select="translate(catalog/cd/artist, $smallcase,
$uppercase)"/></td>
<td><xsl:value-of
select="translate(catalog/cd/artist,
$uppercase,$smallcase)"/></td>
</tr>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
|