Page 177 - Building Digital Libraries
P. 177
CHAPTER 7
specifically the animals and people in the pictures. Using this document,
several XSLT transformations can be applied to generate different displays
for this document. For example, if one wanted to generate an HTML docu-
ment sorted by title from this XML source, one would need to utilize an
XSLT document like the following:
<?xml version=“1.0” encoding=“UTF-8” ?>
<xsl:stylesheet version=“1.0” xmlns:xsl=“http://www.w3.org/1999/XSL/Transform”>
<xsl:template match=“/”>
<html>
<head>
<title>Kenny’s trip to the Zoo</title>
</head>
<body>
<table>
<xsl:for-each select=“ZooTrip/photo”>
<xsl:sort select=“@title” />
<tr>
<td>
<table>
<tr>
<td valign=“top”>
<xsl:call-template name=“print_image”>
<xsl:with-param name=“filename” select=“@filename” />
</xsl:call-template>
<br />
<xsl:call-template name=“print_title”>
<xsl:with-param name=“title” select=“@title” />
</xsl:call-template>
<xsl:call-template name=“print_animals”>
<xsl:with-param name=“name” select=“animals/name” />
</xsl:call-template>
<xsl:call-template name=“print_people”>
<xsl:with-param name=“name” select=“people/name” />
</xsl:call-template>
</td>
</tr>
</table>
</td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
<xsl:template name=“print_image”>
<xsl:param name=“filename” />
<img>
<xsl:attribute name=“src”>
<xsl:value-of select=“$filename” />
</xsl:attribute>
<xsl:attribute name=“style”>zoom:15%</xsl:attribute>
</img>
</xsl:template>
<xsl:template name=“print_title”>
<xsl:param name=“title” />
<b>Title:</b>
<xsl:value-of select=“$title” />
<br />
</xsl:template>
162