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="MyNSublisher"/>
<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="MyNSrgname"/>
</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="MyNSersonname"/>
</xs:sequence>
</xs:restriction>
</xs:complexContent>
</xs:complexType>
</xs:element>
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="MyNSublisher"/>
<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="MyNSrgname"/>
</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="MyNSersonname"/>
</xs:sequence>
</xs:restriction>
</xs:complexContent>
</xs:complexType>
</xs:element>