Stage 2: Configure the stylesheet

Next we build a stylesheet for the Page View using a combination of XHTML and XSLT. The complete W3C specification for XSLT is available at www.w3c.org/tr/xslt.

Our example is quite simple and is based on the W3C's Literal Result Element as Stylesheet specification. Before we proceed with building the stylesheet, consider this illustration taken from the W3C specification:

<html xsl:version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/TR/xhtml1/strict">
	<head>
		<title>Expense Report Summary</title>
	</head>
	<body>
		<p>Total Amount: <xsl:value-of select="expense-report/total"/></p>
	</body>
</html>

Note the following:

  1. The xsl:version attribute must be added to the opening <html> tag; this indicates the XSL version that the stylesheet requires. Simply copy and paste this as is.
  2. The page and text is formatted using standard XHTML tags.
  3. The XSLT value-of element together with the select attribute define the pathway to and name of the data to be used by the Page View (information that is found in the xmldata.xml file created in the previous Stage).

Configuring a stylesheet for the Page View is done with a combination of XHTML and XSLT and can be achieved using an XSL editor or a WYSIWYG web development tool.

Tip: If you wish to modify sample code rather than creating a stylesheet from scratch, proceed to Use the Sample Code below. It may however be worth looking at Use an XSL Editor in order to understand how a stylesheet is created.