RE: [xsl] RE: XPath expression to perform 'keyword' query

Subject: RE: [xsl] RE: XPath expression to perform 'keyword' query
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Thu, 16 Oct 2003 02:42:38 +0100
> 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

<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"/>

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:

Current Thread