Is there something in XPath like "element inheritance"?
Added by Markus Karg over 11 years ago
Sorry for posting this partly off-topic XPath question here, but I don't know a better forum for this (maybe someone shares a link to one?) :-)
I sometimes have the need to issue "polymorphic queries" in XPath. For example, I have an XML document to transform consisting of and , where and both inherit from (in an OOP sense). So I query for select='Apple | Pear'. That obviously works, but it would be great to simply query for select='Fruit' instead, and have a schema declared which makes clear that Apples and Pears actually are Fruits.
Is something like that possible and what is the XSL / XPath Syntax to do that in SAXON?
Thanks! -Markus
Replies (5)
Please register to reply
RE: Is there something in XPath like "element inheritance"? - Added by Michael Kay over 11 years ago
If Apple and Pear are defined in the schema as members of the substitution group whose head is Fruit, then the expression schema-element(Fruit) will select them both.
RE: Is there something in XPath like "element inheritance"? - Added by Markus Karg over 11 years ago
Cool, thanks for this tip! :-) Is this possible in SAXON 9 HE or do I need to buy PE / EE?
RE: Is there something in XPath like "element inheritance"? - Added by Michael Kay over 11 years ago
This feature comes with schema-aware XPath, which requires Saxon-EE.
RE: Is there something in XPath like "element inheritance"? - Added by Markus Karg over 11 years ago
I see. But looking at the price we need to pay for SAXEN EE to give away to all customers, I think my boss would like to go on with the "Union" notation. Anyways, thanks for letting me nknow! ;-)
RE: Is there something in XPath like "element inheritance"? - Added by Michael Kay over 11 years ago
In an ideal world the price of a feature would always be a little bit less than its value, but it's not always possible to achieve that. Sorry!
Please register to reply