Building the Style Sheet

Now that we've got the basics down, let's start building our style sheet. The style sheet we'll use to process our XML document is actually an XML document itself, so let's start with the root element, as shown in Listing 2.2.

Listing 2.4. catalog.xsl: The Most Basic Style Sheet
1: <?xml version="1.0"?>
2: <xsl:stylesheet>
3: </xsl:stylesheet>

There's not a lot to this style sheet. In fact, it has only two items, really: the processing instruction on line 1 to tell the program (in this case, the browser) that this is an XML document, and the root element, <xsl:stylesheet>.

That root element, though, is something new. The xsl: part is to tell the browser that there's something special about this tag; it's not part of ...

Get XML and Java™ from scratch now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.