O'Reilly logo

Real World XML by Steven Holzner

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

XSL Stylesheets

Here's what the stylesheet ch13_02.xsl might look like. In this case, I'm converting ch13_01.xml into HTML, stripping out the names of the planets, and surrounding those names with HTML <P> elements:

Listing . ch13_02.xsl
 
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

    <xsl:template match="PLANETS">
        <HTML>
            <xsl:apply-templates/>
        </HTML>
    </xsl:template>

    <xsl:template match="PLANET">
        <P>
            <xsl:value-of select="NAME"/>
        </P>
    </xsl:template>

</xsl:stylesheet>

Alright, we've got an XML document and the stylesheet we'll use to transform it. So how exactly do you transform the document?

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required