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

RE: RE: XPath expression to perform 'keyword' query

Subject: RE: RE: XPath expression to perform 'keyword' query
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Thu, 16 Oct 2003 02:42:38 +0100
xpath space
> 
> I forgot to mention that the keywords are supplied to the 
> processor as a 
> parameter and are therefore a string of white-space separated values.
> 
> I've just (I think) found a solution with SAXON:
> 
> <xsl:for-each select="//item[.//* = saxon:tokenize($keywords)]">
> 

I suggest you take the call on saxon:tokenize out of the predicate, put
the result in a global variable. (Saxon will attempt to optimize, but
it's difficult to optimize calls on extension functions very much).

You didn't mention that each keyword was a separate element in your
data. Given this property, you should get much better performance by
doing

<xsl:key name="k" match="item" use=".//*[not(*)]"/>
<xsl:variable name="search" select="saxon:tokenize($keywords)"/>
<xsl:variable name="result" select="key('k', $search)"/>

<xsl:template match="/">
  <xsl:copy-of select="$results"/>
</xsl:template>

However, this relies on re-using the index built to support the key
across multiple transformations. Saxon will do this provided that both
the source document and the compiled stylesheet are only built once, and
not rebuilt for each transformation.

Michael Kay



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.