[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Type inheritance in XML Schema
Hi all, I want to use the concept of type inheritance in W3C XML Schema. I am trying to write a small Schema for the same. Below is my attempt. <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="unqualified" attributeFormDefault="unqualified"> <xs:complexType name="shape"> <xs:all> <xs:element name="id" type="xs:string" /> <xs:element name="attr2" type="xs:string" /> </xs:all> </xs:complexType> <xs:complexType name="circle"> <xs:complexContent> <xs:extension base="shape"> <xs:all> <xs:element name="radius" type="xs:float" /> </xs:all> </xs:extension> </xs:complexContent> </xs:complexType> <xs:complexType name="rectangle"> <xs:complexContent> <xs:extension base="shape"> <xs:all> <xs:element name="side1" type="xs:float" /> <xs:element name="side2" type="xs:float" /> <xs:element name="side3" type="xs:float" /> <xs:element name="side4" type="xs:float" /> </xs:all> </xs:extension> </xs:complexContent> </xs:complexType> <xs:element name="OBJECTS"> <xs:complexType> <xs:all> <xs:element name="A" type="circle"/> <xs:element name="B" type="rectangle"/> </xs:all> </xs:complexType> </xs:element> </xs:schema> I am creating a base type called "shape". The subtypes "circle" and "rectangle" derive from this base type. I want to use something like xs:all, because I want to keep the elements unordered. But the above XML Schema is wrong, and the validator complains about xs:all. My questions are.. 1) What will be the right syntax for type inheritance for the requirement above? 2) Will trying to map the OO inheritance concepts to XML Schema be the right design approach? -- Regards, Mukul Gandhi
[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] |
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|