XSL Conditional Logic

   



Generating HTML Documents

Listing A.6 displays the contents of the file bookHTML1.xsl, which demonstrates how to apply an XSL stylesheet to the XML data in book.xml in order to generate an HTML table.

Listing A.6 bookHTML1.xsl

start example
<?xml version="1.0"?> <xsl:stylesheet      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"      version="1.0"> <xsl:template match="/">   <html><body>   <table border="1">     <tr>       <th>Number</th>       <th>Length</th>       <th>Description</th>     </tr>     <xsl:apply-templates/>   </table>   </body></html> </xsl:template> <!-- IMPORTANT: don't include a leading "/" --> <xsl:template match="chapters/chapter">   <xsl:for-each select=".">     <tr>       <td><xsl:value-of select="./number"/></td>       <td><xsl:value-of select="./length"/></td>       <td><xsl:value-of select="./desc"/></td>     </tr>   </xsl:for-each> </xsl:template> <xsl:template match="author|title|desc|appendices"> </xsl:template> </xsl:stylesheet>
end example



   



Fundamentals of SVG Programming. Concepts to Source Code
Fundamentals of SVG Programming: Concepts to Source Code (Graphics Series)
ISBN: 1584502983
EAN: 2147483647
Year: 2003
Pages: 362

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net