[XML-DEV Mailing List Archive Home]
[By Thread]
[By Date]
[Recent Entries]
[Reply To This Message]
Restrict with an extension
- From: Olivier Cailloux <olivier.cailloux@ecp.fr>
- To: xml-dev@lists.xml.org
- Date: Mon, 04 Oct 2010 13:57:45 +0200

Hello,
We are trying to implement a (supposedly) simple hierarchy in which we
would like to have a type Function which has a descendant:
LinearFunction (adds a few elements to the base Function). We also have
a Criterion, which contains a Function, and want to have a
LinearCriterion (derived from Criterion) which also contains a Function
but which must necessarily be of type LinearFunction. I can provide a
diagram if useful.
How should we implement this in XSD? We thought of the following, which
fails for a reason I don't understand. (This schema does not really
make sense but is a minimal example to show the problem.)
<schema xmlns=http://www.w3.org/2001/XMLSchema
xmlns:xs=http://www.w3.org/2001/XMLSchema
targetNamespace=http://www.example.org/xmcda-dev
xmlns:xmcda=http://www.example.org/xmcda-dev
elementFormDefault="qualified">
<complexType name="Function"
abstract="true"></complexType>
<complexType name="LinearFunction">
<complexContent>
<extension base="xmcda:Function">
<sequence>
<element name="point" type="string" minOccurs="2"
maxOccurs="unbounded"></element>
</sequence>
</extension>
</complexContent>
</complexType>
<complexType name="Criterion">
<sequence>
<element name="utilityFunction"
type="xmcda:Function"
minOccurs="1" maxOccurs="1"></element>
</sequence>
</complexType>
<complexType name="LinearCriterion">
<complexContent>
<restriction base="xmcda:Criterion">
<sequence>
<element name="utilityFunction"
type="xmcda:LinearFunction"
minOccurs="1" maxOccurs="1"></element>
</sequence>
</restriction>
</complexContent>
</complexType>
</schema>
Validation fails on the LinearCriterion type with the following errors.
- derivation-ok-restriction.5.4.2: Error for type
'LinearCriterion'. The particle of the type is not a valid restriction
of the particle of the base.
- rcase-NameAndTypeOK.7: The type of element 'utilityFunction',
'LinearFunction', is not derived from the type of the base element,
'Function'.
However it seems to me that LinearFunction is derived from the
type Function. It seems to me that we can't use an extended type
(LinearFunction compared to Function) in a restricted type, is that
true? If yes, why is it so? And how should we proceed?
Any pointer would be appreciated. We searched a lot for this but
couldn't find any clear explanation about this precise case.
Olivier
|

[Date Prev]
| [Thread Prev]
| [Thread Next]
| [Date Next]
--
[Date Index]
| [Thread Index]
|
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format
RSS 2.0 |
 |
Atom 0.3 |
 |
|
Stylus Studio has published XML-DEV in RSS and ATOM formats,
enabling users to easily subcribe to the list from their preferred news reader application.
|
Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website.
they were not included by the author in the initial post. To view the content without the Sponsor Links please
click here.
|
|