xml schema and derivation by restriction

Discussion in 'XML' started by hre1@lycos.de, Dec 28, 2004.

  1. Guest

    hallo,

    after numerous hours of searching for an explanation, i'm deadlocked.
    here is my xsd:

    <xs:complexType name="ct_1">
    <xs:sequence>
    <xs:element name="a1">
    <xs:complexType>
    <xs:sequence>
    <xs:element name="b1"/>
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    <xs:element name="a2" minOccurs="0">
    <xs:complexType>
    <xs:sequence>
    <xs:element name="b2"/>
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    <xs:element name="a3" minOccurs="0">
    <xs:complexType>
    <xs:sequence>
    <xs:element name="b3"/>
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    </xs:sequence>
    </xs:complexType>
    <xs:complexType name="ct_2">
    <xs:complexContent>
    <xs:restriction base="ct_1">
    <xs:sequence>
    <xs:element name="a1">
    <xs:complexType>
    <xs:sequence>
    <xs:element name="b1"/>
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    <xs:element name="a2" minOccurs="0">
    <xs:complexType>
    <xs:sequence>
    <xs:element name="b2"/>
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    </xs:sequence>
    </xs:restriction>
    </xs:complexContent>
    </xs:complexType>
    </xs:schema>

    SCO means:TYPE REFINEMENT ERROR (content type incompatible with the
    content type of the basetype)

    and

    XML Spy 2005 SP1 says: the content model of complex type ct_2 is not a
    valid restriction of the content model of ct_1

    but why? can anybody enlight me?

    thanks in advance
    jeff
    , Dec 28, 2004
    #1
    1. Advertising

  2. Jeff,

    The following will solve your problem. I created complex types for a1, a2,
    and a3 and referenced them within ct_1 and ct_2.

    <xs:complexType name="a1">
    <xs:sequence>
    <xs:element name="b1"/>
    </xs:sequence>
    </xs:complexType>
    <xs:complexType name="a2">
    <xs:sequence>
    <xs:element name="b2"/>
    </xs:sequence>
    </xs:complexType>
    <xs:complexType name="a3">
    <xs:sequence>
    <xs:element name="b3"/>
    </xs:sequence>
    </xs:complexType>

    <xs:complexType name="ct_1">
    <xs:sequence>
    <xs:element name="a1" type="a1" />
    <xs:element name="a2" type ="a2" minOccurs="0" />
    <xs:element name="a3" minOccurs="0" />
    </xs:sequence>
    </xs:complexType>
    <xs:complexType name="ct_2">
    <xs:complexContent>
    <xs:restriction base="ct_1">
    <xs:sequence>
    <xs:element name="a1" type="a1" />
    <xs:element name="a2" type="a2" />
    </xs:sequence>
    </xs:restriction>
    </xs:complexContent>
    </xs:complexType>

    --
    Stan Kitsis
    Program Manager, XML Technologies
    Microsoft Corporation

    This posting is provided "AS IS" with no warranties, and confers no rights.
    Use of included script samples are subject to the terms specified at
    http://www.microsoft.com/info/cpyright.htm


    <> wrote in message
    news:...
    > hallo,
    >
    > after numerous hours of searching for an explanation, i'm deadlocked.
    > here is my xsd:
    >
    > <xs:complexType name="ct_1">
    > <xs:sequence>
    > <xs:element name="a1">
    > <xs:complexType>
    > <xs:sequence>
    > <xs:element name="b1"/>
    > </xs:sequence>
    > </xs:complexType>
    > </xs:element>
    > <xs:element name="a2" minOccurs="0">
    > <xs:complexType>
    > <xs:sequence>
    > <xs:element name="b2"/>
    > </xs:sequence>
    > </xs:complexType>
    > </xs:element>
    > <xs:element name="a3" minOccurs="0">
    > <xs:complexType>
    > <xs:sequence>
    > <xs:element name="b3"/>
    > </xs:sequence>
    > </xs:complexType>
    > </xs:element>
    > </xs:sequence>
    > </xs:complexType>
    > <xs:complexType name="ct_2">
    > <xs:complexContent>
    > <xs:restriction base="ct_1">
    > <xs:sequence>
    > <xs:element name="a1">
    > <xs:complexType>
    > <xs:sequence>
    > <xs:element name="b1"/>
    > </xs:sequence>
    > </xs:complexType>
    > </xs:element>
    > <xs:element name="a2" minOccurs="0">
    > <xs:complexType>
    > <xs:sequence>
    > <xs:element name="b2"/>
    > </xs:sequence>
    > </xs:complexType>
    > </xs:element>
    > </xs:sequence>
    > </xs:restriction>
    > </xs:complexContent>
    > </xs:complexType>
    > </xs:schema>
    >
    > SCO means:TYPE REFINEMENT ERROR (content type incompatible with the
    > content type of the basetype)
    >
    > and
    >
    > XML Spy 2005 SP1 says: the content model of complex type ct_2 is not a
    > valid restriction of the content model of ct_1
    >
    > but why? can anybody enlight me?
    >
    > thanks in advance
    > jeff
    Stan Kitsis [MSFT], Dec 29, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Benjamin Michotte

    derivation, restriction, extension, ...

    Benjamin Michotte, Sep 5, 2003, in forum: XML
    Replies:
    1
    Views:
    489
    Bob Foster
    Sep 5, 2003
  2. Dietmar Gräbner
    Replies:
    1
    Views:
    375
    Priscilla Walmsley
    Jul 19, 2004
  3. Replies:
    1
    Views:
    373
    Stan Kitsis [MSFT]
    Dec 29, 2004
  4. Replies:
    3
    Views:
    459
    Henry S. Thompson
    Jan 7, 2005
  5. Steven T. Hatton
    Replies:
    12
    Views:
    1,687
    Jonathan Turkanis
    Aug 20, 2004
Loading...

Share This Page