Page 179 - Building Digital Libraries
P. 179
CHAPTER 7
<xsl:choose>
<xsl:when test=“$type=‘collection’“>p</xsl:when>
<xsl:when test=“$type=‘dataset’“>m</xsl:when>
<xsl:when test=“$type=‘event’“>r</xsl:when>
<xsl:when test=“$type=‘image’“>k</xsl:when>
<xsl:when test=“$type=‘interactive resource’“>m</xsl:when>
<xsl:when test=“$type=‘service’“>m</xsl:when>
<xsl:when test=“$type=‘software’“>m</xsl:when>
<xsl:when test=“$type=‘sound’“>i</xsl:when>
<xsl:when test=“$type=‘text’“>a</xsl:when>
<xsl:otherwise>a</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name=“leader07”>
<xsl:choose>
<xsl:when test=“$type=‘collection’“>c</xsl:when>
<xsl:otherwise>m</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:value-of select=“concat(‘ ‘,$leader06,$leader07,’ 3u ‘)”/>
</xsl:element>
<xsl:for-each select=“//dc:title[1]”>
<datafield tag=“245” ind1=“0” ind2=“0”>
<subfield code=“a”>
<xsl:value-of select=“.”/>
</subfield>
</datafield>
</xsl:for-each>
<xsl:for-each select=“//dc:title[position()>1]”>
<datafield tag=“246” ind1=“3” ind2=“3”>
<subfield code=“a”>
<xsl:value-of select=“.”/>
</subfield>
</datafield>
</xsl:for-each>
The above XSLT snippet comes from a larger XSLT document capable of
transforming Dublin Core metadata to MARC21XML. Looking at this
snippet, a number of things become apparent. First, the XSLT document
itself is a valid XML document, with a number of namespaces defined at
the top of the file. A valid XSLT file must define all namespaces that will be
utilized during the process—and as such, we see namespaces defined for
xsl, dc (Dublin Core), and MARC21XML, which is defined as the primary
namespace. Within the file, conditional operations like xsl:for-each and xsl:if
are used to evaluate the current document being transformed.
The XSLT specification has evolved significantly over the past decade.
While the specification still lacks many of the elements needed to be a
formal programming language, it has been expanded to include a wide
array of data-processing, sorting, grouping, and matching functionality. In
fact, it is the richness of the feature set that remains the primary difference
between the various XSLT versions. As of this writing, XSLT currently has
three versions of the specification. Version 1.0 represents the most basic
incarnation of the stylesheet language, and is the version supported by
all modern web browsers. And while version 1.0 has not been formally
164