xml - How to make xsd element extend another -



xml - How to make xsd element extend another -

i have 3 different xml elements have mutual tags.

for e.g: person has name, age, sex have manager, employee share 3 fields person has plus manager, employee specific fields managerno, employeeno etc.

can write in xsd this

1. declare person element

<xsd:element name="person"> <xsd:annotation> <xsd:documentation>person request</xsd:documentation> </xsd:annotation> <xsd:complextype> <xsd:sequence> <xsd:element name="personname" type="xsd:string" minoccurs="1" maxoccurs="1" /> <xsd:element name="age" type="xsd:integer" minoccurs="1" maxoccurs="1" /> </xsd:sequence> </xsd:complextype> </xsd:element> use above person declaration , extend manager element:

(just thought of looking for)

in effect, trying mimic schema definition per java (object oriented) inheritance like:

public class person { string name; int age; // getters , setters above variables go here }

then do:

public class manager extends person { int managerno; string departmentname; } public class employee extends person { int employeeno; string designation; // getters/setters , other code goes here }

i want mimic java inheritance concept in xsd such can declare 1 base of operations element, , extend base of operations element such other kid elements inherit properties of base of operations element.

thanks in advance.

simply use:

<xs:extension base="addresstype">

in manager/employye schema definition

<xs:complextype name="manager"> <xs:complexcontent> <xs:extension base="person"> <xs:sequence> <!-- properties --> </xs:sequence> </xs:extension> </xs:complexcontent> </xs:complextype>

xml xsd wsdl

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

c# - Can ProtoBuf-Net deserialize to a flat class? -

javascript - Change element in each JQuery tab to dynamically generated colors -