Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


[xsl] XSLT key() function document argument

From: Bill French <french@---------.--->
To: "xsl-list@-----.------------.---" <--------@-----.------------.--->
Date: 11/3/2009 1:17:00 AM
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

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe@l...>
--~--



transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent