I have defined two complex element types - Developer and App.
Developer childs - ID ,Name, Email
App childs - ID, Name, Developer
Here the Developer in App complex element refers to Developer/ID.
How to define this relationship in xml schema. I am using XML spy2013 editor.
I have tried specifying name in the declaration of simple type Developer->ID. And using this name in App->Developer datatype. But it gives error..
<?xml version="1.0" encoding="UTF-8"?>
<!-- edited with XMLSpy v2013 (x64) (http://www.altova.com) by Piyush (USC) -->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="appinfo">
<xs:complexType>
<xs:sequence>
<xs:element name="Developer">
<xs:complexType>
<xs:all>
**<xs:element name="ID">**
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:length value="5"/>
<xs:pattern value="[a-zA-Z][a-zA-Z][0-9][0-9][a-zA-Z]"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="Name">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="([a-zA-Z])+"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="Email">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="[^@]+@[^\.]+\..+"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="Company" type="xs:string"/>
<xs:element name="Website" type="xs:string"/>
<xs:element name="Phone">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:length value="13"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:all>
</xs:complexType>
</xs:element>
<xs:element name="App">
<xs:complexType>
<xs:all>
<xs:element name="ID">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:length value="5"/>
<xs:pattern value="[0-9][0-9][0-9][0-9][A-Z]"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="Name">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="([a-zA-Z])+"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="Developer" ***type="xs:anySimpleType"/>***
<xs:element name="Price">
<xs:simpleType>
<xs:restriction base="xs:float">
<xs:minInclusive value="0.00"/>
<xs:maxInclusive value="6.99"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="TabletCompatible" type="xs:boolean" minOccurs="0"/>
<xs:element name="Category">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="Travel"/>
<xs:enumeration value="Productivity"/>
<xs:enumeration value="Game"/>
<xs:enumeration value="Music"/>
<xs:enumeration value="Education"/>
<xs:enumeration value="Lifestyle"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="Platform">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="Android"/>
<xs:enumeration value="iOS"/>
<xs:enumeration value="Blackberry"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:all>
</xs:complexType>
</xs:element>
<xs:element name="AppStat">
<xs:complexType>
<xs:all>
<xs:element name="AppID" type="xs:anySimpleType"/>
<xs:element name="Statistics">
<xs:complexType>
<xs:sequence maxOccurs="unbounded">
<xs:element name="Platform" type="xs:anySimpleType"/>
<xs:element name="Downloads" type="xs:positiveInteger"/>
<xs:element name="Rating">
<xs:simpleType>
<xs:restriction base="xs:float">
<xs:minInclusive value="0.0"/>
<xs:maxInclusive value="5.0"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="LastChecked" type="xs:date"/>
</xs:all>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>