XML technologies / XSLT / Introduction to XSLT 2.0 / Getting started with XSLT and XPath / Stylesheets with multiple templates / Input for processing: an XML address directory
(Excerpt from "XSLT 2.0 & XPath 2.0" by Frank Bongers, Chapter 1.)
For the next example, we will use a slightly more complex source document that could be an excerpt from an XML address directory. The people and addresses are entirely fictional.
<?xml version="1.0" encoding="ISO-8859-1"?>
<adressen>
<!-- eine Adresse: -->
<adresse>
<name>
<vorname>Peter</vorname>
<nachname>Mustermann</nachname>
</name>
<anschrift>
<plz>12345</plz>
<ort>Beispielshausen</ort>
<strasse>Wagenstr.</strasse>
<nr>5a</nr>
</anschrift>
</adresse>
...
<!-- viele weitere Adressen wie die obere -->
...
</adressen>
Code example: kap01/1.15.1/adressen.xml (excerpt).
The address list should now be output as HTML. Initially, each address will simply be placed in a paragraph, giving a result roughly as follows:
<html>
<head>
<title>Adressenliste</title>
</head>
<body>
<h1>Adressenliste</h1>
<p>Peter Mustermann 12345 Beispielshausen Wagenstr. 5a</p>
<p>Holger Hurtig 22345 Randstetten Am Niemandsland 2</p>
<!-- weitere Adressen -->
</body>
</html>
Copyright © Galileo Press, Bonn 2008
You may print the online version for your private use.
Otherwise, this chapter from "XSLT 2.0 & XPath 2.0 ― Das umfassende Handbuch" is subject to the same terms as the printed edition: the work and all its parts are protected by copyright. All rights are reserved, including reproduction, translation, microfilming, and storage and processing in electronic systems.
Galileo Press, Rheinwerkallee 4, 53227 Bonn