[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Using keys to lookup from current stylesheet

Subject: Using keys to lookup from current stylesheet
From: Justin Makeig <lists@xxxxxxxxxx>
Date: Fri, 07 Nov 2003 13:36:15 -0800
justin makeig
I'm trying to use a key to lookup elements in the current stylesheet. The
AcronymnStandsFor is called from another stylesheet that imports the one
shown below to populate the @title attribute of xhtml:acronym elements.
I've used Michael Kay's advice from his book and used the for-each
select="document('')" to switch the context to the current (stylesheet)
document. However, the key doesn't seem to find anything. I've tested that
the values that are coming in in the $acronym parameter are correct. Can
anybody spot what the problem might be? Thanks.

- Justin

<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:a="http://cde.berkeley.edu/docbook/constant/acronym"
    exclude-result-prefixes="a">
    
    <xsl:key name="AcronymKey" match="a:acronymItem" use="a:acronym"/>
    
    <xsl:template name="AcronymnStandsFor">
        <xsl:param name="acronym"/>
        <!-- change context to current document so the key will work -->
        <xsl:for-each select="document('')">
            <xsl:value-of select="key('AcronymKey',$acronym)/a:standsFor"/>
        </xsl:for-each>
    </xsl:template>
    
    <!-- acronym lookups -->
    <a:acronymList>
        <a:acronymItem>
            <a:acronym>Ant</a:acronym>
            <a:standsFor>Another Neat Tool</a:standsFor>
        </a:acronymItem>
        ...
    </a:acronymList>
</xsl:stylesheet>


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.