Re: Speeding up processing (with sablotron or saxon)
At 10:57 AM 7/13/2004, you wrote:
So I'd replace the:- <xsl:for-each select=".//resource[not(@swgcraft_id=preceding::*/@swgcraft_id)]">
Yeah, sorry I didn't wrap it up completely -- now you can have
...but it will be much more efficient, since the set has already been collected -- the processor doesn't now have to look at every resource in the document, checking all of their preceding siblings, to establish which are unique.
This finding-the-unique-one business ("deduplicating") is one of the relatively few common tasks -- maybe the most important -- for which XPath 1.0 has no direct provision, requiring us XSLT 1.0 hackers to master a couple of tricky idioms.
Another way to do it you may have just seen in another thread. Instead of
<xsl:variable name="unique-resources" select="$resources[not(count(.|key('resources-by-id',@swgcraft_id)) = 1)]"/>
(Hey! isn't there a glitch here! isn't that 'not' erroneous? Oops ... I think I should have offered $resources[count(.|key('resources-by-id',@swgcraft_id)) = 1]) ...)
you can have
select="$resources[generate-id() = generate-id(key('resources-by-id',@swgcraft_id))]"/>
which does the same thing, but in a different way ... and because of the way a string function is defined to work over a node set, can be obscured further to simply
$resources[generate-id() = generate-id(key('resources-by-id',@swgcraft_id))]
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