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

XSLT key() function document argument

Subject: XSLT key() function document argument
From: Bill French <french@xxxxxxxxxxxxx>
Date: Mon, 02 Nov 2009 17:16:36 -0800
 XSLT key() function document argument
Hi all,

I have a stylesheet that initializes some keys based on content in the input document. Then, the stylesheet applies templates to a node set variable whose contents come from an external file. For awhile I was very confused, because the keys weren't accessible from the templates that were being applied in the different context.

<xsl:key name="c" match="rm:content" use="string(@name)"/>
<xsl:key name="l" match="rm:label" use="string(@name)"/>
<xsl:variable name="orig-context" select="/"/>

...

<xsl:variable name="wf">
    <xsl:copy-of select="document($wf-filepath)"></xsl:copy-of>
</xsl:variable>

<xsl:template match="/rm:contentList">
    <xsl:apply-templates select="$wf"/>
</xsl:template>

<xsl:template match="rm:insert[@label]">
    <xsl:apply-templates select="key('l', @label, $orig-context)"/>
</xsl:template>

The variable $wf contains the rm:insert elements that are matched by the final template.

Now the question is -- is there a way to reference the "original" context, i.e., the document that processor originally encounters as the input tree? I've stored the document in the variable $orig-context, but this doesn't seem like an efficient or particularly elegant solution. Is there some special syntax to access the original context from a context created when applying templates to a node set variable?

Many thanks,

--Bill

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.