xsl-list
[Top] [All Lists]

RE: [xsl] XPath for matching multiple child elements

2006-09-29 00:17:59
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/


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--