Stylesheet example

For those keen to get started with XSLT, the following stylesheet is a simple but working example that can be modified and extended to test the concepts described in the following chapters:

<xsl:stylesheet
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        xmlns="http://www.w3.org/TR/xhtml1/strict">

  <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="author">
    <H3><xsl:apply-templates/></H3>
  </xsl:template>

  <xsl:template match="publisher">
    <P><I><xsl:apply-templates/></I></P>
  </xsl:template>

</xsl:stylesheet>

This stylesheet can be used to process XML source documents such as the following:

<book>
  <title>My Life</title>
  <author>J. Smith</author>
  <publisher>ACME Publishing</publisher>
  ...
</book>

It converts these documents into HTML documents that can be viewed in any popular Web browser:

<HTML>
  <BODY>
    <H1>My Life</H1>
    <H3>J. Smith</H3>
    <P><I>ACME Publishing</I></P>
  </BODY>
</HTML>

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset