W3C home > Mailing lists > Public > www-xml-schema-comments@w3.org > January to March 2004

[Fwd: [Moderator Action] Free occurrence of foreign-namespaced elements]

From: C. M. Sperberg-McQueen <cmsmcq@acm.org>
Date: 26 Jan 2004 17:04:41 -0700
To: W3C XML Schema Comments list <www-xml-schema-comments@w3.org>
Message-Id: <1075161881.2639.18.camel@localhost>


attached mail follows:




I am developing an XML grammar for representing Java code constructs. I
would like the base document to be freely extensible by introducing
elements from other namespaces anywhere between the elements of the base
grammar. In validation, such elements should simply be ignored with no
complexity added to the process.

There is no provision for this in XML Schema. The only provision is an
explicit wildcard-particle "any." It has to be included in each content
model, at each possible place in each sequence and as a part of any
choice. There are even additional complexities with elements with
maxOccurs > 1, they have to be nested inside a choice between the
element and "any."

I feel that it is one of the great advantages of XML over plain text
that it naturally affords the distinction between the primary content
and "orthogonal extensions," simply by discerning between element
namespaces. The same provision has always been the Achilles' heel of the
traditional plain-text formats for source code. Extensions are
introduced inside comments and have to be parsed by a separately
developed parser.

The very essence of XML is extensibility. I think that the concept of
orthogonal document extensions is one very important aspect of it. That
the XML Schema does not provide for it might be a big disadvantage.

In the remainder of this message, I offer an example of my idea.

This is an example of a document with an orthogonal extension:

  <compilation-unit xmlns="http://example.com/java"
xmlns:t="http://example.com/java/template">
    <class name="ClassA">
      <method name="equals">
        <t:template-equals>
          <t:conditions>
            <t:automatic/>
          </t:conditions>
        </t:template-equals>
        <instance access="public">
          <returns>boolean</returns>
          <parameter name="o">
            <type>Object</type>
          </parameter>
          <body/>
        </instance>
      </method>
    </class>
  </compilation-unit>

In the example, the elements with prefix t: belong to an extension. 

I tried to develop an XML Schema that would explicitly allow such an
extension to occur at each particular place. It looked something like
this:

  <xs:element name="compilation-unit">
    <xs:complexType>
      <xs:sequence>
        <xs:any namespace="##other" processContents="lax" minOccurs="0"
maxOccurs="unbounded"/>
        <xs:element name="member-of" minOccurs="0"/>
        <xs:choice minOccurs="0" maxOccurs="unbounded">
          <xs:any namespace="##other" processContents="lax"/>
          <xs:element name="import"/>
        </xs:choice>
        <xs:sequence maxOccurs="unbounded">
          <xs:choice>
            <xs:element name="class"/>
            <xs:element name="interface"/>
          </xs:choice>
          <xs:any namespace="##other" processContents="lax"
minOccurs="0" maxOccurs="unbounded"/>
        </xs:sequence>
      </xs:sequence>
    </xs:complexType>
  </xs:element>

Without allowing extensions, only this is required:

  <xs:element name="compilation-unit">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="member-of" minOccurs="0"/>
        <xs:element name="import" minOccurs="0" maxOccurs="unbounded"/>
        <xs:choice maxOccurs="unbounded">
          <xs:element name="class"/>
          <xs:element name="interface"/>
        </xs:choice>
      </xs:sequence>
    </xs:complexType>
  </xs:element>

I would like that XML Schema provided for something like this:

  <xs:element name="compilation-unit">
    <xs:complexType>
      <xs:sequence allowForeignElements="true">
        <xs:element name="member-of" minOccurs="0"/>
        <xs:element name="import" minOccurs="0" maxOccurs="unbounded"/>
        <xs:choice maxOccurs="unbounded">
          <xs:element name="class"/>
          <xs:element name="interface"/>
        </xs:choice>
      </xs:sequence>
    </xs:complexType>
  </xs:element>

The value of the attribute allowForeignElements pertains to all the
subgroups in the sequence as well.

Marko 
Received on Monday, 26 January 2004 19:13:50 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 23:09:01 UTC