A Simple XSL Style Sheet

The best way to get a feel for how XSL style sheets work is to see one in action. Listing 23.1 shows an XML file describing two people. Notice the <?xml-stylesheet?> processing instruction that specifies the name of the XSL style sheet that accompanies this XML file.

Code Listing 23.1. Source Code for Person.xml
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="PersonToHTML.xsl"?>
<people>
    <person>
        <firstName>Samantha</firstName>
        <middleName>Lauren</middleName>
        <lastName>Tippin</lastName>
        <age>7</age>
    </person>
    <person>
        <firstName>Kaitlynn</firstName>
        <middleName>Dawn</middleName>
        <lastName>Tippin</lastName>
        <age>4</age>
    </person>
</people>
					

Listing 23.2 shows the PersonToHTML.xsl style sheet that translates ...

Get Special Edition Using Java™ 2 Enterprise Edition 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.