Listing 1
<?xml version="1.0"?>
<?xml:stylesheet type="text/xsl" href="listing2.xsl"?>
<topic><title>Separating Content from Presentation
</title><body></body>
<topic>
<title>Introduction</title>
<body>
<p>You've probably heard the propaganda by now: XML blesses
you with a way to separate content from presentation.
Separation in turn yields productive gains over HTML and
other data formats used to manage content. What makes
all this possible? XSLT.
</p>
</body>
</topic>
<topic><title>XSLT</title><body><p>Extensible Stylesheet
Language for Transformations, or XSLT, is a functional
programming language that enables us to bridge the gap
between content and presentation by providing a means of
specifying how a content-based XML document is transformed
into a presentation-oriented document or data format.
</p></body><topic>
<title>XSL History</title>
<body>
<p>The birth of XSLT breaks down like this: Extensible
Stylesheet Language (XSL) was conceived as an XML
application for expressing stylesheets capable of
manipulating XML documents. After its submission to the W3C
in 1997, XSL split into two stylesheet standards:
Extensible Stylesheet Language for Transformations (XSLT)
and Extensible Stylesheet Language Formatting Objects
(XSL-FO). </p>
</body>
<topic><title>XPath</title><body><p>The early XSL proposals
also gave rise to another breakaway standard, XPath. It
grew out of the location-finding aspects of the XSL and
XPointer specifications, which had been independently using
similar mechanisms to find information in XML documents.
XSLT relies on XPath to locate specific nodes or node sets
within XML documents. </p>
</body></topic><topic><title>CSS</title><body><p>XSL has
another related standard, though unlike XSL it is not
based in XML: Cascading Style Sheets (CSS). In the
context of web publishing, Cascading Style Sheets (CSS)
can also be used, at least theoretically, to statically
format XML documents for display, but it cannot be used
to transform them in any meaningful way.</p>
</body></topic></topic></topic></topic>
Listing 2
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl=
"http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="iso-8859-1"
indent="yes" />
<xsl:template match="/">
<html>
<head>
<style type="text/css">
.titleHead { font-family: helvetica, arial, sans-serif;
font-size: 160%; font-weight: bold; color: #804000; }
</style>
<!-- <link rel="stylesheet" type="text/css" href=
"ss/mystyles.css" /> -->
<meta http-equiv="author" content="Steve Hoenisch"/>
<title><xsl:value-of select="topic/title" /></title>
</head>
<body class="base">
<span class="titleHead"><xsl:value-of select=
"topic/title" /><br/></span>
<hr size="1" width="100%" color="brown"/>
<xsl:apply-templates select="topic/topic"/>
</body>
</html>
</xsl:template>
<xsl:template match="topic">
<h1><xsl:value-of select="title" /></h1>
<p><xsl:value-of select="body/p" /></p>
</xsl:template>
</xsl:stylesheet>
Listing 3
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl=
"http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="iso-8859-1"
indent="yes" />
<xsl:template match="topic/title">
<html>
<head>
<style type="text/css">
.titleHead { font-family: helvetica, arial, sans-serif;
font-size: 160%; font-weight: bold; color: #804000; }
</style>
<!-- <link rel="stylesheet" type="text/css" href=
"ss/mystyles.css" /> -->
<meta http-equiv="author" content="Steve Hoenisch"/>
<title><xsl:value-of select="." /></title>
</head>
<body class="base">
<div class="content_target">
<span class="titleHead"><xsl:value-of select="." /><br/></span>
<hr size="1" width="100%" color="brown"/>
<xsl:apply-templates select="topic"/>
</div>
</body>
</html>
</xsl:template>
<xsl:template match="topic/topic/title">
<h1><xsl:value-of select="." /></h1>
</xsl:template>
<xsl:template match="topic/topic/topic/title">
<h2><xsl:value-of select="." /></h2>
</xsl:template>
<xsl:template match="topic/topic/topic/topic/title">
<h3><xsl:value-of select="." /></h3>
</xsl:template>
<xsl:template match="topic/topic/topic/topic/topic/title">
<h4><xsl:value-of select="." /></h4>
</xsl:template>
<xsl:template match="topic/topic/topic/topic/topic/topic/title">
<h5><xsl:value-of select="." /></h5>
</xsl:template>
<xsl:template match="p">
<p><xsl:value-of select="." /></p>
</xsl:template>
</xsl:stylesheet>
Listing 4
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>XSL Switch</title>
<script language="JScript">
function transformPage(strStylesheetName) {
// Reference the results DIV element in the HTML page.
// This is where the results of the tranformatin will go.
var objResults = document.all['results'];
// Create two new DOM Document instances:
var objXML = new ActiveXObject('MSXML2.DOMDocument.3.0');
var objXSL = new ActiveXObject('MSXML2.DOMDocument.3.0');
// Set the parser properties
objXML.validateOnParse = true;
objXSL.validateOnParse = true;
// Load the XML source document:
objXML.load('listing1.xml');
// Load the XSLT stylesheet.
objXSL.load(strStylesheetName);
// Invoke the transformNode method to perform the transformation:
strResult = objXML.transformNode(objXSL);
// Place the results in the div element of the HTML page:
objResults.innerHTML = objXML.transformNode(objXSL);
}
</script>
</head>
<body onLoad="transformPage('listing2.xsl')">
<button onClick="transformPage('listing3.xsl')">View Entire Document</button>
<button onClick="transformPage('listing2.xsl')">View Summary</button>
<hr size="1" width="100%" color="brown">
<div id="results">
</div>
</body>
</html>