File: Data.xml
<book>
<chapter>
<title>From Book I</title>
<para>para1</para>
<para>para2</para>
</chapter>
<afterword>
<para>para 3</para>
</afterword>
<appendix>
<title>Glossary</title>
<para>A</para>
<para>B</para>
</appendix>
</book>
File: Transform.xslt
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="html" />
<xsl:template match="chapter | appendix | afterword">
<xsl:apply-templates />
</xsl:template>
<xsl:template match="*">
<h1>
<xsl:value-of select="name()" />
ELEMENT UNACCOUNTED FOR BY STYLESHEET:
<xsl:apply-templates />
</h1>
</xsl:template>
<xsl:template match="book">
<html>
<body>
<xsl:apply-templates />
</body>
</html>
</xsl:template>
<xsl:template match="title">
<h1>
<xsl:apply-templates />
</h1>
</xsl:template>
<xsl:template match="chapter/para">
<paragraph>
<font face="times">
<xsl:apply-templates />
</font>
</p>
</xsl:template>
<xsl:template match="appendix/para">
<paragraph>
<font face="arial">
<xsl:apply-templates />
</font>
</p>
</xsl:template>
</xsl:stylesheet>
Output:
<html>
<body>
<h1>From Book I</h1>
<paragraph><font face="times">para1</font></p>
<paragraph><font face="times">para2</font></p>
<h1>para
ELEMENT UNACCOUNTED FOR BY STYLESHEET:
para 3
</h1>
<h1>Glossary</h1>
<paragraph><font face="arial">A</font></p>
<paragraph><font face="arial">B</font></p>
</body>
</html>
|