Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > How to use abstract element in schema?

Reply
Thread Tools

How to use abstract element in schema?

 
 
Leo
Guest
Posts: n/a
 
      01-16-2005
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>
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Abstract Methods & Abstract Class Iyer, Prasad C Python 0 10-20-2005 06:35 AM
About abstract class and abstract method Sameer Java 4 08-31-2005 12:59 AM
Deriving abstract class from non-abstract class Matthias Kaeppler Java 1 05-22-2005 01:28 PM
Abstract class with no abstract functions Uzytkownik C++ 3 04-03-2005 05:45 PM
Abstract Classes w/o abstract methods DaKoadMunky Java 4 04-20-2004 04:53 AM



Advertisments