[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Speeding up processing (with sablotron or saxon)

Subject: Re: Speeding up processing (with sablotron or saxon)
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Tue, 13 Jul 2004 11:33:19 -0400
Re:  Speeding up processing (with sablotron or saxon)
Hi Tony,

At 10:57 AM 7/13/2004, you wrote:

So I'd replace the:-


<xsl:key name="resource-by-id" match="resource" use="@swgcraft_id"/>
<xsl:variable name="resources" select="//resource"/>
<xsl:variable name="unique-resources"
= 1)]"/>

but I guess I still need some form of for-each statement too?

Yeah, sorry I didn't wrap it up completely -- now you can have

<xsl:for-each select="$unique-resources">...</xsl:for-each>

...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"
= 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]) = 1]) ...)

you can have

<xsl:variable name="unique-resources"
select="$resources[generate-id() = generate-id(key('resources-by-id',@swgcraft_id)[1])]"/>

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))]


====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================

Current Thread


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.