236 The XML Files: Develo pment of XML/XSL Applications Using WebS phere Studio
</html>
The CustomerResult.xsl needs to construct an HTML file, and it should
match that data from the XML data representation to insert it into the
HTML file. So, in the code in Example 10-10, the XSL tem plate puts the
skeleton of the HTML document, specifying the necessary HTML tags, like
head, body, etc. In the HTML body section, the XSL file specifies another
template the matches the customer root element of the XM L data. So, the
HTML body represents a customer.
Example 10-10 Sample of CustomerResult stylesheet form
<xsl:template match="/">
<html>
<head>
<title>Customer Registration Information</title>
<style type="text/css">
<![CDATA[
body
{
background-color: #f8f7cd;
}
h3
{
color: #0000ff;
text-align: center;
}
]]>
</style>
</head>
<body>
<xsl:apply-templates select="Customer"/>
</body>
</html>
</xsl:template>
Example 10-11 shows the code for the customer template representing to
be inserted in the HTML body. First it includes a heading representing the
title of the page, then an HTML table is created for displaying the data.
The table includes four templates to be matched from the XML data, which
are the membership, firstName, lastName, and e-mail. So, the XSL
selected from the XML files the element values representing the data.
Example 10-11 Stylesheet template for customer information representation
<xsl:template match="Customer">
<h3>Customer Registration Information</h3>
<table border="0" cellpadding="2" cellspacing="0">
<xsl:apply-templates select="membership"/>