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

RE: XPath for matching multiple child elements

Subject: RE: XPath for matching multiple child elements
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Fri, 29 Sep 2006 08:17:39 +0100
xpath child nodes not matching
> Probably this would be faster?
> 
> <xsl:stylesheet version="2.0"
>  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>  >
> 
>  <xsl:key name="kComDesc" match="h1|p|b|i"
>    use="exists(ancestor::Comments[1])"/>
> 
>  <xsl:template match="key('kComDesc', 'true')">
>    Whatever processing here
>  </xsl:template>
> </xsl:stylesheet>

Yes, that would probably work reasonably well (and it's nice to find a
plausible use case for using key() in a pattern). One point to be careful
about though: if the "use" value is a boolean, the second parameter of key()
should also be a boolean, so it should be key('kComDesc', true()). There's
no implicit casting in 2.0, and non-comparable values are treated as not
matching, so you can get some hard-to-diagnose errors in this area.

The "[1]" suggests you don't have much confidence in your product's
optimizer...

Michael Kay
http://www.saxonica.com/

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-2007 All Rights Reserved.