W3C home > Mailing lists > Public > xmlschema-dev@w3.org > January 2003

modifiying the extension mechanism in XML schema

From: Erik Curiel <erik@gaffle.com>
Date: Sun, 29 Dec 2002 18:27:45 -0800 (PST)
To: <xmlschema-dev@w3.org>, <www-xml-schema-comments@w3.org>, Lorin Kobashigawa-Bates <lorin@gaffle.com>, Phil Suh <phil@filsa.net>
Message-ID: <Pine.BSO.4.33.0212291826480.23088-100000@maria.gaffle.com>


I want to suggest an addition to the current specification, to make
defining new types by extending existing ones more flexible.

An example will make clearer the issue I'm addressing.

Say one has the following type definition:

  <xs:complexType name="textType">
    <xs:sequence>
      <xs:element name="paragraph" type="paragraphType"
        maxOccurs="unbounded"/>
    </xs:sequence>
  </xs:complexType>

and one wants to modify it so that before the sequence of <paragraph> tags
in an instance document there comes a <title> tag.  As things now stand,
because the extension mechanism appends any new parts of the extended
type's content model to the content model of the base type, one would have
explicitly to define a new type:

  <xs:complexType name="textWithTitleType">
    <xs:sequence>
      <xs:element name="title" type="xs:string"/>
      <xs:element name="paragraph" type="paragraphType"
        maxOccurs="unbounded"/>
    </xs:sequence>
  </xs:complexType>

It seems that it would be more flexible if one could specify whether one
wanted extensions to an existing type's content model to be prepended to
it or appended to it, something like:

  <xs:complexType name="textWithTitleType">
    <xs:complexContent>
      <xs:extension base="textType" insert="prepend">
        <xs:element name="title" type="xs:string"/>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>

The "insert" attribute of <xs:extension> could be defaulted to "append",
for backwards compatibility.

Thank you for your consideration.

Yours,
Erik Curiel
Received on Tuesday, 7 January 2003 13:35:57 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:14:35 GMT