XML technologies / XSLT / Introduction to XSLT 2.0 / XSLT and XPath – getting started / Summary and exercises / Exercises

(Excerpt from “XSLT 2.0 & XPath 2.0” by Frank Bongers, chapter 1.)

For these exercises, use AltovaXML or Saxon 9 as the XSLT processor (or its GUI Kernow). Installation and operation of the processors are described in XSLT 2.0 processors.

The solutions are in Solutions to the exercises.

The source material is a simple XML document containing a short text message, rather like an email. (Note: Peter Panter and Theobald Tiger were pseudonyms used by Kurt Tucholsky as a critic.)

<?xml version="1.0" encoding="ISO-8859-1"?> 
<memo>
  <an>Peter Panter</an> 
  <von>Theobald Tiger</von> 
  <betreff>Neues Buch von Tucholsky</betreff> 
  <text>Hallo Peter! Hast Du schon das neue Buch von Tucholsky gelesen? Gruss, Theo!</text> 
</memo>

Code example: aufgaben/kap01/memo1.xml.

An unfinished stylesheet is available for processing; complete it:

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:template ...>
    <html>
      <body>
        <h1>Memo:</h1>
        ...
      </body>
    </html>
  </xsl:template> 
</xsl:stylesheet>

Code example: aufgaben/kap01/memo.xsl.

<?xml version="1.0" encoding="ISO-8859-1"?>
<buch titel="XML – Das verflixte Attribut" autor="Mike Müller" uebersetzer="Peter Panter" verlag="Galileo Computing" isbn="0 815 12345 0" ersch-jahr="2010"/>

Code example: aufgaben/kap01/buch-attrib.xml.

Create a stylesheet containing a template matching the document node. Put the basic HTML structure inside it. Add xsl:value-of instructions to read the attributes. Try to obtain formatting roughly as follows:
Mike Miller: »XML – Das verflixte Attribut« in der Übersetzung von Peter Panter Galileo Computing, 2010

   

back to top