Hej
Her er xsl-koden og xml-koden
XSL-dokumentet
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="
http://www.w3.org/1999/XSL/Transform"
xmlns:JavaXML="
http://www.oreilly.com/catalog/javaxml/"
version="1.0"
>
<xsl:template match="JavaXML:Book">
<html>
<head>
<title><xsl:value-of select="JavaXML:Title" /></title>
</head>
<body>
<xsl:apply-templates select="*[not(self::JavaXML:Title)]" />
</body>
</html>
</xsl:template>
<xsl:template match="JavaXML:Contents">
<center>
<h2>Table of contents</h2>
</center>
<hr />
<u1>
<xsl:for-each select="JavaXML:Chapter">
<xsl:choose>
<xsl:when test="@focus='Java'">
<li><xsl:value-of select="JavaXML:Heading" /> (Java Focus)</li>
</xsl:when>
<xsl:otherwise>
<li><xsl:value-of select="JavaXML:Heading" /> (XML Focus)</li>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</u1>
</xsl:template>
<xsl:template match="JavaXML:References">
<p>
<center><h3>Useful references</h3></center>
<ol>
<xsl:for-each select="JavaXML:Reference">
<li>
<xsl:element name="a">
<xsl:attribute name="href">
<xsl:value-of select="JavaXML:Url" />
</xsl:attribute>
<xsl:value-of select="JavaXML:Name" />
</xsl:element>
</li>
</xsl:for-each>
</ol>
</p>
</xsl:template>
<xsl:template match="JavaXML:Copyright">
<xsl:copy-of select="*" />
</xsl:template>
</xsl:stylesheet>
XML-dokumentet:
<?xml version="1.0"?>
<?xml-stylesheet href="JavaXML.html.xsl" type="text/xsl"?>
<?xml-stylesheet href="XSL\JavaXML.wml.xsl" type="text/xsl" media="wap"?>
<?cocoon-process type="xslt"?>
<!--
<!DOCTYPE JavaXML:Book SYSTEM "JavaXML.dtd">
-->
<!-- Java and XML -->
<JavaXML:Book xmlns:JavaXML="
http://www.oreilly.com/catalog/javaxml/"
publicationDate="June 2000">
<JavaXML:Title>Java and XML</JavaXML:Title>
<JavaXML:Contents>
<JavaXML:Chapter focus="XML">
<JavaXML:Heading>Introduction</JavaXML:Heading>
<JavaXML:Topic subSections="7">What is it?</JavaXML:Topic>
<JavaXML:Topic subSections="3">How do I use it?</JavaXML:Topic>
<JavaXML:Topic subSections="4">What is next?</JavaXML:Topic>
</JavaXML:Chapter>
<JavaXML:Chapter focus="XML">
<JavaXML:Heading>Creating XML</JavaXML:Heading>
<JavaXML:Topic subSections="0">An XML Document</JavaXML:Topic>
<JavaXML:Topic subSections="2">The Header</JavaXML:Topic>
<JavaXML:Topic subSections="6">The Content</JavaXML:Topic>
<JavaXML:Topic subSections="1">What is next?</JavaXML:Topic>
</JavaXML:Chapter>
<JavaXML:Chapter focus="Java">
<JavaXML:Heading>Parsing XML</JavaXML:Heading>
<JavaXML:Topic subSections="3">Getting preparred</JavaXML:Topic>
<JavaXML:Topic subSections="3">SAX Readers</JavaXML:Topic>
<JavaXML:Topic subSections="9">Content Handlers</JavaXML:Topic>
<JavaXML:Topic subSections="4">Error handlers</JavaXML:Topic>
<JavaXML:Topic subSections="0">A better way to load a
parser</JavaXML:Topic>
<JavaXML:Topic subSections="4">"Gotcha!"</JavaXML:Topic>
<JavaXML:Topic subSections="0">What is next?</JavaXML:Topic>
</JavaXML:Chapter>
<JavaXML:SectionBreak/>
<JavaXML:Chapter focus="Java">
<JavaXML:Heading>Web publishing frameworks</JavaXML:Heading>
<JavaXML:Topic subSections="4">Selecting a framework</JavaXML:Topic>
<JavaXML:Topic subSections="4">Installation</JavaXML:Topic>
<JavaXML:Topic subSections="3">Using a publishing
framework</JavaXML:Topic>
<JavaXML:Topic subSections="2">XSP</JavaXML:Topic>
<JavaXML:Topic subSections="3">Cocoon 2.0 and beyond</JavaXML:Topic>
<JavaXML:Topic subSections="0">What is next?</JavaXML:Topic>
</JavaXML:Chapter>
</JavaXML:Contents