RE: [xsl] Keys working on nodeset?

Subject: RE: [xsl] Keys working on nodeset?
From: "Andrew Welch" <ajwelch@xxxxxxxxxxxxxxx>
Date: Mon, 25 Jul 2005 14:12:47 +0100
> <?xml version="1.0" encoding="iso-8859-1" ?>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
> <xsl:param name="Input" select="''"/>
> <xsl:key name="key-test" match="Something" use="some-attribute"/>
>
> <xsl:template match="/">
>   <xsl:for-each select="$Input/Root-element">
>     <xsl:for-each select="key('key-test',Something/@some-attribute)">
>       Do something
>     </xsl:for-each>
>   <xsl:for-each>
> </xsl:template>
> </xsl:stylesheet>

This is interesting in that you want to key on a document that is passed
in as a parameter.  This should work fine, but I've certainly never done
it.  Instead, I pass the XML into the stylesheet as a string and then
use the extension saxon:parse() on it to create a nodeset.  This is
simpler than doing the work in the host language.

This is useful when the XML that is passed in as a paramter is created
dynamically, if the document already exists at the end of a url you
should use the document() function - isn't that sufficient for what you
need here?

Cheers
andrew

Current Thread