This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Re: RE: Re: XPath riddle


Hi Nikolaos,

> with this schema
[snip]
> 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
problem.

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:

  E[not(parent::V/parent::RRR)]

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

  E[not(../parent::RRR)]

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.
  
Cheers,

Jeni

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


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]