How to use abstract element in schema?

Discussion in 'XML' started by Leo, Jan 16, 2005.

  1. Leo

    Leo Guest

    In my XML file, I have to elements: "person" and "organization", which
    are exchangable. Since these two elements are nearly identical, I plan
    to write an abstract element "agent" in my schema and let "person" and
    "organization" inherit from "agent". However, my schema is invalid.
    Can anyone please point out what my problem is. Thanks a million in
    advance!

    Leo

    The following is my XML instance file:
    <datacreator>
    <organization>
    <orgname>...</orgname>
    <address>...</address>
    <contact>...</address>
    </organization>
    </datacreator>
    <publisher>
    <person>
    <personname>
    <firstName>...</firstName>
    <lastName>...</lastName>
    </personname>
    <address>...</address>
    <contact>...</address>
    </person>
    </publisher>


    The following is my schema:

    <xs:element ref="MyNS:datacreator"/>
    <xs:element ref="MyNS:publisher"/>

    <xs:element name="datacreator">
    <xs:complexType>
    <xs:sequence>
    <xs:element ref="MyNS:agent"/>
    </xs:sequence>
    </xs:complexType>
    </xs:element>

    <xs:element name="publisher">
    <xs:complexType>
    <xs:sequence>
    <xs:element ref="MyNS:agent"/>
    </xs:sequence>
    </xs:complexType>
    </xs:element>

    <xs:element name="agent">
    <xs:complexType>
    <xs:sequence>
    <xs:element ref="MyNS:address"/>
    <xs:element ref="MyNS:contact"/>
    </xs:sequence>
    </xs:complexType>
    </xs:element>

    <xs:element name="organization">
    <xs:complexType>
    <xs:complexContent>
    <xs:restriction base="MyNS:agent">
    <xs:sequence>
    <xs:element ref="MyNS:eek:rgname"/>
    </xs:sequence>
    </xs:restriction>
    </xs:complexContent>
    </xs:complexType>
    </xs:element>

    <xs:element name="person">
    <xs:complexType>
    <xs:complexContent>
    <xs:restriction base="MyNS:agent">
    <xs:sequence>
    <xs:element ref="MyNS:personname"/>
    </xs:sequence>
    </xs:restriction>
    </xs:complexContent>
    </xs:complexType>
    </xs:element>
    Leo, Jan 16, 2005
    #1
    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. DaKoadMunky
    Replies:
    4
    Views:
    541
    Lee Weiner
    Apr 20, 2004
  2. Matthias Kaeppler
    Replies:
    1
    Views:
    420
    R.F. Pels
    May 22, 2005
  3. Markus
    Replies:
    1
    Views:
    1,497
    Markus
    Nov 23, 2005
  4. Stanimir Stamenkov
    Replies:
    3
    Views:
    1,170
    Stanimir Stamenkov
    Apr 25, 2005
  5. Replies:
    1
    Views:
    501
    George Bina
    Jul 20, 2006
Loading...

Share This Page