VOResource v1.0 IWD

Arnold Rots arots at head.cfa.harvard.edu
Fri Jun 10 14:11:47 PDT 2005


Hay Ray,

OK, here is to your challenge to produce something that can be done
with substitution groups (SG) but not with xsi:type.

As I said, one major problem is the lack of a nesting mechanism for
xsi:type (which could have been solved by allowing xsi:type in schemata).

So, very simply, I want to define a generic element, and a generic
container for such generic elements.  Now I derive specialized
elements from the generic element and a specialized container from the
generic container that holds those specialized elements.

This leads to the two schemata that I have appended.  The trouble is
that the xsi:type version does not validate, whereas the SG one does.
At least - I don't see how one can do it for the former.

The issue here is retaining the inheritance concept for the container
as well as for its contents.

Enjoy!

  - Arnold

--------------------------------------------------------------------------
Arnold H. Rots                                Chandra X-ray Science Center
Smithsonian Astrophysical Observatory                tel:  +1 617 496 7701
60 Garden Street, MS 67                              fax:  +1 617 495 7356
Cambridge, MA 02138                             arots at head.cfa.harvard.edu
USA                                     http://hea-www.harvard.edu/~arots/
--------------------------------------------------------------------------


xsi:type version:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
  <xs:complexType name="baseElementType">
    <xs:sequence/>
  </xs:complexType>
  <xs:complexType name="baseContainerType">
    <xs:sequence maxOccurs="unbounded">
      <xs:element name="MyBaseElement" type="baseElementType"/>
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="mySpecialElementType">
    <xs:complexContent>
      <xs:extension base="baseElementType"/>
    </xs:complexContent>
  </xs:complexType>
  <xs:complexType name="mySpecialContainerType">
    <xs:complexContent>
      <xs:restriction base="baseContainerType">
        <xs:sequence>
          <xs:element name="SpecialElement" type="mySpecialElementType"/>
        </xs:sequence>
      </xs:restriction>
    </xs:complexContent>
  </xs:complexType>
</xs:schema>



SG version:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
  <xs:complexType name="baseElementType">
    <xs:sequence/>
  </xs:complexType>
  <xs:element name="BaseElement" abstract="true" type="baseElementType"/>
  <xs:complexType name="baseContainerType">
    <xs:sequence maxOccurs="unbounded">
      <xs:element ref="BaseElement"/>
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="mySpecialElementType">
    <xs:complexContent>
      <xs:extension base="baseElementType"/>
    </xs:complexContent>
  </xs:complexType>
  <xs:element name="SpecialElement" type="mySpecialElementType" substitutionGroup="BaseElement"/>
  <xs:complexType name="mySpecialContainerType">
    <xs:complexContent>
      <xs:restriction base="baseContainerType">
        <xs:sequence>
          <xs:element ref="SpecialElement"/>
        </xs:sequence>
      </xs:restriction>
    </xs:complexContent>
  </xs:complexType>
</xs:schema>



More information about the registry mailing list