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

Re: optimization of complex XPath

Subject: Re: optimization of complex XPath
From: Graydon <graydon@xxxxxxxxx>
Date: Fri, 19 Nov 2010 05:19:36 -0500
Re:  optimization of complex XPath
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

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

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.
Email
First Name
Last Name
Company
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.