O'Reilly logo

Special Edition Using XML, Second Edition by - et al. David Gulbransen

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

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="http://www.w3.org/1999/XSL/Transform" >

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 ...

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