Re: [xsl] Re: RE: Re: XPath riddle

Subject: Re: [xsl] Re: RE: Re: XPath riddle
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Fri, 6 Jul 2001 18:55:02 +0100
Hi Nikolaos,

> with this schema
> how would you select all Es of type A? Stating explicitly that RRR
> may not appear in the wanted Es ancestors would not do (I guess),
> because that would mean that partly identical paths should be
> identified beforehand etc.

You could be asking two questions here.

First, you might be asking how to get at the fact that an element E is
of type A and use that in a stylesheet. The short answer to that is
you can't, not with XPath 1.0. XML Schema wasn't around when XPath 1.0
was designed, so there's no support for accessing information from an
XML Schema. If you want to get information from the schema, you can
use the fact that XML Schema documents are XML documents, access them
using the document() function, and work through the schema to work out
what type a particular element is. Trust me, this is not easy. On the
positive side, come XPath 2.0 you should be able to do this no

The second question you might be asking is, given that structure of
your XML document, how can you pick those particular E elements. Note
that your XML instance does not match the schema that you gave - I'm
working from the schema, not the instance. From your schema, it looks
as though you want to exclude those E elements that are children of V
elements and grandchildren of RRR elements. You can do this with:


or, given that in your schema E elements can't be grandchildren of RRR
elements without being children of V elements:


Alternatively, you could try to match those E elements that occur in
situations that you *are* interested in, i.e. those that are children
of V elements that are children of C elements, or that are children of
D elements:

  E[parent::V/parent::C or parent::D]

Selecting all the E elements that fulfill these criteria is a matter
of adding '//' at the start of the patterns above.


Jeni Tennison

 XSL-List info and archive:

Current Thread