[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Type inheritance in XML Schema

  • From: "Mukul Gandhi" <gandhi.mukul@g...>
  • To: xml-dev@l...
  • Date: Thu, 20 Sep 2007 19:11:51 +0530

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!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.