Re: [xsl] Using XSLT's key() function while context in secondary document?

Subject: Re: [xsl] Using XSLT's key() function while context in secondary document?
From: Michael Ludwig <mlu@xxxxxxxxxxxxx>
Date: Wed, 20 Feb 2008 13:10:08 +0100
Scott Trenda schrieb:
Alternatively, you could do the same with a little less code:

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
  <xsl:key name="chnam" match="Chnl" use="@ID" />
  <xsl:template match="/">
    <Urmel>
      <xsl:for-each select="key('chnam', document('s.xml')//Channel)">
        <p><xsl:value-of select="@ID"/> this works</p>
      </xsl:for-each>
    </Urmel>
  </xsl:template>
</xsl:stylesheet>

Thanks a lot, Scott - this is perfectly suited for my purposes and looks much better!

I was wondering whether all those context changes were costly operations
but decided it didn't matter enough to bother. Thanks to your help, the
context changes are eliminated and the code is lean and clean.

Michael

Current Thread