How to use abstract element in schema?

L

Leo

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>
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,815
Latest member
treekmostly22

Latest Threads

Top