Creating Frames

Problem

You want to generate HTML that organizes content by using HTML frames.

Solution

As in Recipe 8.2, you will use modes to make multiple passes over the XML. First, create the frameset container document. To do so, you use two frames. The smaller left frame holds the names of the salespeople as hyperlinks for activating content in the mainframe. The main frame contains the sales figures for the salesperson selected by the user. This example provides a default main frame that is displayed when the page first comes up:

<xsl:stylesheet version="1.1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html"/> <xsl:param name="URL"/> <xsl:template match="/"> <xsl:apply-templates select="*" mode="frameset"/> <xsl:apply-templates select="*" mode="salespeople_frame"/> <xsl:apply-templates select="*" mode="sales_frames"/> </xsl:template> <!-- = = = = = = = = = = = = = = = = = = = = = = = = = = --> <!-- Create frameset container (mode ="frameset") --> <!-- = = = = = = = = = = = = = = = = = = = = = = = = = = --> <xsl:template match="salesBySalesperson" mode="frameset"> <!-- Non-standard saxon xsl:document! --> <xsl:document href="index.html"> <html> <head> <title>Salesperson Frameset</title> </head> <frameset rows="100%" cols="25%, 75%" border="0"> <frame name="salespeople" src="salespeople_frame.html" noresize=""/> <frame name="mainFrame" src="default_sales.html" noresize=""/> </frameset> <body bgcolor="#FFFFFF" text="#000000"> </body> </html> </xsl:document> ...

Get XSLT Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.