Examples of XML Transformation

Estudies4you
Examples of XML Transformation
Example 2:XSLT Stylesheet(list2.xsl)
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xs1="http://www.w3.org/1999./XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h1>Sales Report</h1>
<xsl:apply-templates select="SalesReport/Header/*"/>
<xsl:apply-templates select="SalesReport/Body"/>
</body>
</html>
</xsl:template>
<xsl:template match="InputDate"> - InputDate:<xsl:value-of select="." /><br/>
</xsl:template> <xsl:template match="PropertyName"> - PropertyName:<xs1:value-of select="." /><br/>
</xsl:template> <xsl:template match="SalesPerson"> - SalesPerson:<xs1:value-of select="." /><br/>
</xsl:template>
<xsl:template match="Body">
<table border="1" width="300">
<tr><th>ProductName</th><th>Price</th><th>Volume</th></tr>
<xsl:apply-templates select="Results"/>
</table>
</xsl:template>
<xsl:template match="Results">
<tr> <td><xs1:value-of select="ProductName" /></td>
<td align="right"><xsl:value-of select="UnitPrice" />
(<xsl:value-of select="UnitPrice/@Units" />)</td>
<td align="right"><xs1:value-of select="Volume" /></td>
</tr>
</xsl:template>
</xs1:stylesheet>


To Top