Exercise 3

Section 7 of this tutorial contains a discussion of the following stylesheet:

<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="collection">
<html>
<head></head>
<body>
<xsl:for-each select="body/letter">
<p>
<b>From <xsl:value-of select="author"/> to
<xsl:value-of select="recipient"/> </b><br/>
<xsl:value-of select="place"/> <br/>
<xsl:value-of select="year"/> <br/>
<xsl:value-of select="callnumber"/>
</p>
</xsl:for-each> </body>
</html>
</xsl:template>
</xsl:stylesheet>

When you look at collection.dtd (this file can be found in the folder that you have downloaded), you will see that all subelements of <letter> are in fact optional, which means that they may not be present.

Change the stylesheet above and make sure that no unneeded HTML tags are added when certain XML elements are not used in the source tree. The element <annotations> can be left out of consideration.

Answers | Continue with the tutorial