XML.orgXML.org
FOCUS AREAS |XML-DEV |XML.org DAILY NEWSLINK |REGISTRY |RESOURCES |ABOUT
OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]
Restrict with an extension

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]


News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 1993-2007 XML.org. This site is hosted by OASIS