DxpHome ||
Samples ||
Details ||
Docs ||
Trees ||
xml-xsl ||
Links
Source for stylesheet recordset.xsl
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<!-- set the output properties -->
<xsl:output method="html"/>
<!-- root rule -->
<xsl:template match="/">
<html>
<head>
<title>XSL Transform Test</title>
</head>
<body bgcolor="#FFFFFF" Text="#000000">
<xsl:apply-templates/>
</body>
</html>
</xsl:template>
<xsl:template match="doc">
<div align="center">
<h3>XSL Transformation on a Recordset</h3>
<xsl:apply-templates/> <!-- apply templates to child nodes (tags enclosed by doc) -->
</div>
</xsl:template>
<!-- how to process the children of a recordset tag -->
<xsl:template match="recordset">
<table border="0" bgcolor="#3399FF">
<xsl:for-each select="labels">
<tr>
<th bgcolor="#CCCCFF">No.</th>
<xsl:for-each select="label">
<th bgcolor="#CCCCFF">
<xsl:value-of select="."/>
</th>
</xsl:for-each>
</tr>
</xsl:for-each>
<xsl:for-each select="row">
<tr>
<td bgcolor="#CCCCFF"><xsl:value-of select="position()"/></td> <!-- row numbers -->
<xsl:for-each select="*"> <!-- for each data elem in row -->
<td bgcolor="#FFFFFF">
<xsl:value-of select="."/> <!-- select content of each elem -->
</td>
</xsl:for-each>
</tr>
</xsl:for-each>
</table>
</xsl:template>
<!-- how to process an info tag -->
<xsl:template match="info">
<table width="450">
<tr><td align="left"><xsl:apply-templates/></td></tr>
</table>
</xsl:template>
<!-- How to process each item in the info tag -->
<xsl:template match="item">
<p><xsl:apply-templates/></p>
</xsl:template>
</xsl:stylesheet>
|