Subject: Re: [xsl] XSLT key() function document argument From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Mon, 02 Nov 2009 20:27:34 -0500 |
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?
-- Upcoming: hands-on XSLT, XQuery and XSL-FO Washington DC Nov 2009 Interested in other classes? http://www.CraneSoftwrights.com/s/i/ Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video Video lesson: http://www.youtube.com/watch?v=PrNjJCh7Ppg&fmt=18 Video overview: http://www.youtube.com/watch?v=VTiodiij6gE&fmt=18 G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Male Cancer Awareness Nov'07 http://www.CraneSoftwrights.com/s/bc Legal business disclaimers: http://www.CraneSoftwrights.com/legal
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] XSLT key() function document , Bill French | Thread | Re: [xsl] XSLT key() function docum, Bill French |
[xsl] XSLT key() function document , Bill French | Date | Re: [xsl] XSLT key() function docum, Bill French |
Month |