On Fri, Nov 19, 2010 at 09:25:50AM +0100, Wolfgang Laun scripsit:
The O(n^2) is due to iterating over a list (for) and then iterating
over the document tree to find //num/@cite.
The following stylesheet should do it better,using xsl:key:
I am reluctant to approach the problem with xsl:key because I have about
90,000 individual files in a complex directory structure and I would
need a key over all of them, rather than each of them.
Since far as I know -- and happy to be wrong! -- I can't declare a key
over a collection, so this approach would require concatenating all of
the files together. Which is certainly doable but also inherently
sluggish.
<?xml version="1.0"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>
<xsl:strip-space elements="*"/>
<xsl:key name="citekey" match="num" use="@cite"/>
<xsl:template match="link">
<xsl:value-of select="(key('citekey',@cite),'ok',concat(@cite,' is
missing'))[2]"/><xsl:text>
</xsl:text>
</xsl:template>
</xsl:stylesheet>
I have tested it with a very primitive XML only:
<doc>
<foo>
<num area="decisions" cite="1"/>
<bar>
<link area="decisions" cite="1"/>
<link area="decisions" cite="2"/>
</bar>
</foo>
</doc>
Thank you!
-- Graydon
--~------------------------------------------------------------------
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>
--~--