W
wanda
Hi,
I am trying to use XML inheritance to define a base class and derived
class that can have elements appear in any order. from what i've read,
i can only extend the base class in sequential order. does anyone know
how to do this? for example, if i want to allow both of these:
<employee>
<firstname>larry</firstname>
<lastname>jones</lastname>
</employee>
<employee>
<lastname>smith</lastname>
<firstname>mary</firstname>
<city>new york</city>
</employee>
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="employee" type="fullpersoninfo"/>
<xs:complexType name="personinfo">
<xs:sequence>
<xs:element name="firstname" type="xs:string"/>
<xs:element name="lastname" type="xs:string"/>
</xs:sequence>
</xs:complexType><xs:complexType name="fullpersoninfo">
<xs:complexContent>
<xs:extension base="personinfo">
<xs:sequence>
<xs:element name="address" type="xs:string"/>
<xs:element name="city" type="xs:string"/>
<xs:element name="country" type="xs:string"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:schema>
I am trying to use XML inheritance to define a base class and derived
class that can have elements appear in any order. from what i've read,
i can only extend the base class in sequential order. does anyone know
how to do this? for example, if i want to allow both of these:
<employee>
<firstname>larry</firstname>
<lastname>jones</lastname>
</employee>
<employee>
<lastname>smith</lastname>
<firstname>mary</firstname>
<city>new york</city>
</employee>
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="employee" type="fullpersoninfo"/>
<xs:complexType name="personinfo">
<xs:sequence>
<xs:element name="firstname" type="xs:string"/>
<xs:element name="lastname" type="xs:string"/>
</xs:sequence>
</xs:complexType><xs:complexType name="fullpersoninfo">
<xs:complexContent>
<xs:extension base="personinfo">
<xs:sequence>
<xs:element name="address" type="xs:string"/>
<xs:element name="city" type="xs:string"/>
<xs:element name="country" type="xs:string"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:schema>