An XML-to-HTML Transformation Example

Now let's look at an example of converting an XML document into an HTML document. We will start with the XML document in Listing 9.2, our travel.xml document, and work to produce an HTML-formatted itinerary.

As with any stylesheet, we start with the stylesheet element and Namespace:

<xsl:stylesheet version="1.0" 
  xmlns:xsl="" >

Next, we specify that the output method is HTML, and we will be indenting again for the sake of readability:

<xsl:output method="html" indent="yes"/> 

The first template will match our root node, and will actually contain all the markup that we will have in the document:

<xsl:template match="/"> 

Now, because we are working with HTML, we can insert ...

Get Special Edition Using XML, Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.