December 2002
Intermediate to advanced
672 pages
16h 53m
English
You want to convert XML into hyperlinked HTML content.
A typical course of action when converting XML into HTML is to make
two or more passes over the XML to create menu or index pages and
content pages. The menu pages contain links to the content pages. The
following solution generates an
index and summary
pages for SalesBySalesPerson.xml (see Chapter 2):
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:saxon="http://icl.com/saxon" extension-element-prefixes="saxon"> <xsl:output method="html"/> <xsl:template match="/"> <xsl:apply-templates select="*" mode="index"/> <xsl:apply-templates select="*" mode="content"/> </xsl:template> <!-- = = = = = = = = = = = = = = = = = = = = = = = = = = --> <!-- Create index.html (mode = "index") --> <!-- = = = = = = = = = = = = = = = = = = = = = = = = = = --> <xsl:template match="salesBySalesperson" mode="index"> <saxon:output href="index.html"> <html> <head> <title>Sales By Salesperson Index</title> </head> <body bgcolor="#FFFFFF" text="#000000"> <h1>Sales By Salesperson</h1> <xsl:apply-templates mode="index"/> </body> </html> </saxon:output> </xsl:template> <xsl:template match="salesperson" mode="index"> <h2> <a href="{concat(@name,'.html')}"> <xsl:value-of select="@name"/> </a> </h2> </xsl:template> <!-- = = = = = = = = = = = = = = = = = = = = = = = = = = --> <!-- Create @name.html (mode = "content") --> <!-- = = = = = = = = = = = = = = = = = = = = = = = = = ...Read now
Unlock full access