xsl-list
[Top] [All Lists]

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

2005-06-15 12:38:13
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
------------------------------------------------------------------------


--~------------------------------------------------------------------
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>
--~--