xsl-list
[Top] [All Lists]

RE: Keys working on nodeset?

2005-07-25 06:12:47


<?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

--~------------------------------------------------------------------
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(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>