[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] document() and keys
Hi XSLT experts, A while ago I asked about how to refer to nodes in the original input while processing another document(). A few of you replied with the excellent suggestion of storing the root of the original document in a global variable: <xsl:variable name="src-root" select="/"/> and then selecting nodes inside it like this: ....select="$src-root//[ some test ]" This works great. But: as some of you might have guessed from the // up there, I now find that I can make the transformation go about 20 times faster if I use keys instead. But I can't see how to make keys work in this multi-document situation. Having searched the archives I established that something like this could work: <xsl:for-each select="$src-root"> .... select="key(keyname,...)" ... </xsl:for-each> I think that this does get the correct nodes (though I'm not 100% sure of it). The problem is that I want to pass the selected node as a parameter to a named template. I have tried this: <xsl:call-template.....> <xsl:for-each select="$src-root"> <xsl:with-param .... select="key(keyname,...)"/> </xsl:for-each> </xsl:call-template> But that's not legal XSL. So I tried putting it in a variable: <xsl:variable name="tmp"> <xsl:for-each select="$src-root"> <xsl:value-of select="key(keyname,...)"/> </xsl:for-each> </xsl:variable> <xsl:call-template.....> <xsl:with-param select="$tmp"/> </xsl:call-template> But that gives the "result fragment not node set" error, so I tried using a conversion extension function (yuk): <xsl:call-template.....> <xsl:with-param select="xalan:nodeset($tmp)"/> </xsl:call-template> But that isn't working either: I think that the nodeset is copying the nodes, so my code in the called template that tries to look up its parents fails to work. Now I've run out of ideas. Help! --Phil. XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|