<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.sam.com/consultants"
xmlns:tns="http://www.sam.com/consultants"
elementFormDefault="qualified">
<!-- instantiating the element
Customer spconsultant=new Customer();
-->
<element name="spconsultant" type="tns:pconsultant" />
<!-- here we are defining complex element complex element similar to class
in java
List<Customer> customer=new ArrayList<Customer>();
-->
<complexType name="pconsultant">
<sequence>
<element name="consultant" type="tns:cconsultant" minOccurs="1"
maxOccurs="unbounded" />
</sequence>
</complexType>
<complexType name="cconsultant">
<sequence>
<element name="name" type="string" maxOccurs="1" minOccurs="1" />
<element name="email" type="string" maxOccurs="2" minOccurs="1" />
<element name="mobile" type="string" maxOccurs="1" minOccurs="1" />
<element name="description" type="string" maxOccurs="1" minOccurs="0" />
<element name="car" type="tns:car" maxOccurs="1" minOccurs="1" />
</sequence>
<!--
Attributes are optional by default. To specify that the attribute is required, use the "use" attribute:
<attribute name="age" type="int" default="20" use="required"/>
-->
<attribute name="age" type="int" default="20"/>
<attribute name="color" type="string" default="white"/>
</complexType>
<simpleType name="car">
<restriction base="string">
<enumeration value="Audi" />
<enumeration value="Golf" />
<enumeration value="BMW" />
</restriction>
</simpleType>
<element name="dog">
<complexType>
<sequence>
<element name="name" type="string" maxOccurs="1" minOccurs="1" />
<element name="email" type="string" maxOccurs="2" minOccurs="1" />
<element name="mobile" type="string" maxOccurs="1"
minOccurs="1" />
<element name="description" type="string" maxOccurs="1"
minOccurs="0" />
</sequence>
</complexType>
</element>
</schema>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.sam.com/consultants"
xmlns:tns="http://www.sam.com/consultants"
elementFormDefault="qualified">
<!-- instantiating the element
Customer spconsultant=new Customer();
-->
<element name="spconsultant" type="tns:pconsultant" />
<!-- here we are defining complex element complex element similar to class
in java
List<Customer> customer=new ArrayList<Customer>();
-->
<complexType name="pconsultant">
<sequence>
<element name="consultant" type="tns:cconsultant" minOccurs="1"
maxOccurs="unbounded" />
</sequence>
</complexType>
<complexType name="cconsultant">
<sequence>
<element name="name" type="string" maxOccurs="1" minOccurs="1" />
<element name="email" type="string" maxOccurs="2" minOccurs="1" />
<element name="mobile" type="string" maxOccurs="1" minOccurs="1" />
<element name="description" type="string" maxOccurs="1" minOccurs="0" />
<element name="car" type="tns:car" maxOccurs="1" minOccurs="1" />
</sequence>
<!--
Attributes are optional by default. To specify that the attribute is required, use the "use" attribute:
<attribute name="age" type="int" default="20" use="required"/>
-->
<attribute name="age" type="int" default="20"/>
<attribute name="color" type="string" default="white"/>
</complexType>
<simpleType name="car">
<restriction base="string">
<enumeration value="Audi" />
<enumeration value="Golf" />
<enumeration value="BMW" />
</restriction>
</simpleType>
<element name="dog">
<complexType>
<sequence>
<element name="name" type="string" maxOccurs="1" minOccurs="1" />
<element name="email" type="string" maxOccurs="2" minOccurs="1" />
<element name="mobile" type="string" maxOccurs="1"
minOccurs="1" />
<element name="description" type="string" maxOccurs="1"
minOccurs="0" />
</sequence>
</complexType>
</element>
</schema>
Thanks to you. Now I am confident about understanding XSD and designing :)
ReplyDelete