O'Reilly logo

XML and Java™ from scratch by Nicholas Chase

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

Transforming an XML File from Within a Java Program

Now that we're getting more comfortable with Java, let's do something really useful: create our product pages. We'll start by using a Java program to create XHTML files that traditional browsers can read even if they don't understand XML.

Creating the Style Sheet

The first thing that we need to do is to create the style sheet that we'll use for transforming the product page. Let's start by getting the basic formatting down, as in Listing 4.16.

Listing 4.16. productpage.xsl: The Overall Style Sheet
 0: <?xml version="1.0"?> 1: <xsl:stylesheet version="1.0" 2: xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 3: 4: <xsl:include href="topinclude.xsl"/> 5: 6: <xsl:template match="//product"> 7: ...

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