Download Java And XSLT

Transcript
<xsl:with-param name="displayName" select="'Jobs'"/>
<xsl:with-param name="url" select="'jobs.xml'"/>
</xsl:call-template>
</xsl:template>
<!-*******************************************************************
** This template produces a "button" in the top navigation bar.
**************************************************************** -->
<xsl:template name="navButton">
<xsl:param name="category"/>
<xsl:param name="displayName"/>
<xsl:param name="url"/>
<xsl:choose>
<!-- The current category is displayed as text -->
<xsl:when test="$category = $global.nav.ca tegory">
<xsl:value-of select="$displayName"/>
</xsl:when>
<!-- All other categories are displayed as hyperlinks -->
<xsl:otherwise>
<a href="{$url}">
<xsl:value-of select="$displayName"/>
</a>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-*******************************************************************
** This template creates the left navigation area.
**************************************************************** -->
<xsl:template name="createLeftNavbar">
Left Navigation Area
</xsl:template>
</xsl:stylesheet>
This stylesheet is quite simple in concept. First, it sets up the global.nav.category variable.
The stylesheet uses XPath to check for the existence of a <meta> tag that contains a
navigationCategory attribute:
<xsl:variable name="global.nav.category">
<xsl:choose>
<xsl:when test="/html/head/meta[@name='navigationCategory']">
<xsl:value-of select="/html/head/meta
[@name='navigationCategory']/@content"/>
</xsl:when>
<xsl:otherwise>
<xsl:text>unknown</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
The first part of the XPath expression used by <xsl:when> locates any <meta> tags:
/html/head/meta
Next, a predicate is used to narrow down the list to the one <meta> tag that contains a
navigationCategory attribute: