Re: : Re: [xsl] complex XPATH test

Subject: Re: : Re: [xsl] complex XPATH test
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Wed, 18 Jul 2001 17:12:03 +0100
Hi Wendell,

> I also note your XPath to find the containing block is more
> efficient than mine (at least in that theoretically it is more
> amenable to optimization :-).

Actually I designed it like that because it's shorter to write and it
ties up with making it extensible. You could create a node set of the
names of block elements:

 <block>p</block>
 <block>li</block>
 <block>blockquote</block>
 ...

You can make this into a node set held by the $block-elements variable
(via a node-set() extension, a variable in processors that support XSLT
1.1, or through the old document('') trick) and then find an ancestor
whose local name was one of these block names:

  ancestor::*[local-name() = $block-elements][1]

But I think you're probably right about the efficiency with it as it
stands. Rule of thumb is that it's better to traverse any particular
axis once rather than traverse it multiple times and union the results
together. It doesn't matter so much with the ancestor axis 'cos it's
usually fairly short, but could make a big difference with
preceding/following.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


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


Current Thread