Re: Sorting using helper structure, position(), xsl:ke
2008/4/10, David Carlisle <davidc@xxxxxxxxx>:in xslt1 you have to be in the right document already, which means that in teh restricted context of xsl:sort you can only use a key if your mappig element is in teh same document as the nodes over which you are iterating.
<xsl:key name="bla-lookup" match="ABC" use="@bla"/>
<!-- top level variable --> <xsl:variable name="main-doc" select="/"/>
<!-- in some template --> <xsl:for-each select="document($secondary-doc)/A/B"> <xsl:variable name="bla" select="@bla"/> <xsl:for-each select="$main-doc"> <xsl:value-of select="key('bla-lookup', $bla)"/> ...
But in the case of xsl:sort, you *cannot* use this idiom, as xsl:sort does not allow you to embed a context switch so you're restricted to what's visible within the context of the secondary document. You must use a variable in this case, which, of course, is unfortunate if the node-set to search is large.
At least that's what I understood.
This seems to be an issue I currently have. I'm using xsltproc, so XSLT 1.0.
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