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 O’Reilly online learning.

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