Re: [xsl] How to select either ElementA -OR- ElementB in an axis

Subject: Re: [xsl] How to select either ElementA -OR- ElementB in an axis
From: Eric van der Vlist <vdv@xxxxxxxxxxxx>
Date: Wed, 15 Jun 2005 21:38:13 +0200
Hi,

On mer, 2005-06-15 at 12:25 -0700, Christopher R. Maden wrote:
> chris wrote:
> > Thanks for the response.  Are you sure that's correct or am I goofing
> > it up somehow?  Using Saxon 8.4, I get an error trying to use your
> > solution...
> 
> No, that won't work.  You need to look at all your ancestors, then find
> the closest one that matches your pattern:
> 
> ancestor::*[name() = 'A' or name() = 'B'][1]

Using name() = 'A' is not namespace safe and self::A should be preferred
in such situations :

ancestor::*[self::ElementA | self::ElementB][1]

Also note that the order of the ancestor axis can be misleading since
you'll get the first one starting from the context node going toward the
document root.

Eric

> 
> HTH,
> Chris
-- 
Curious about Relax NG? Read my book online.
                                   http://books.xmlschemata.org/relaxng/
------------------------------------------------------------------------
Eric van der Vlist       http://xmlfr.org            http://dyomedea.com
(ISO) RELAX NG   ISBN:0-596-00421-4 http://oreilly.com/catalog/relax
(W3C) XML Schema ISBN:0-596-00252-1 http://oreilly.com/catalog/xmlschema
------------------------------------------------------------------------

Current Thread