W3C home > Mailing lists > Public > xmlschema-dev@w3.org > April 2002

Re: Schema Design: Composition vs Subclassing

From: Jeff Rafter <jeffrafter@defined.net>
Date: Tue, 2 Apr 2002 23:38:30 -0600
Message-ID: <013e01c1dad1$c9687250$32f5d90c@C1980223A>
To: "Roger L. Costello" <costello@mitre.org>, <xmlschema-dev@w3.org>

> What are your thoughts on this?  /Roger

I have run into the same issues-- one of the determining factors is what I
am using as my "base class" or XML Schema base type. In general I agree that
using group is a much better and scalable design. It avoids all kinds of
nasty stuff.  OTOH, I have found it easier when designing XML Schemas that
actually represent Object Oriented serialized Objects that the only logical
way is by using inheritence.

The reason for this is that the generating software may not have the ability
to introspect all levels (depending on language and availability). For
example let's say I am doing this in Delphi (Object Pascal)--

My base type will look something like

<xs:complexType name="TObject">
      maxOccurs="unbounded" />
  <xs:attribute name="order" type="xs:positiveInteger" />
  <xs:attribute name="flags" type="xs:string" />
  <xs:attribute name="id" type="xs:ID" />

It is a TObject that may contain an unlimited number of TObjects. At this
level I have no idea what will use this as its ancestor in the future. In
the future I may have a "TComponent" that adds properties (subelements), but
can still contain multiple TObject descendents within it.

<xs:complexType name="TComponent">
    <xs:extension base="target:TPersistent">
          minOccurs="0" />
          minOccurs="0" />
          minOccurs="0" />

This allows me to use the xsi:type facility within the instance document to
actually specify what kind of TObject I am using in the instance.

All the best,
Jeff Rafter
Defined Systems
XML Development and Developer Web Hosting
Received on Wednesday, 3 April 2002 00:40:26 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 14:55:56 UTC