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

Forwarded message 1

  • From: Marko Topolnik <marko.topolnik@fer.hr>
  • Date: Tue, 20 Jan 2004 09:37:52 -0500 (EST)
  • Subject: [Moderator Action] Free occurrence of foreign-namespaced elements
  • To: <www-xml-schema-comments@w3.org>
  • Message-ID: <002401c3df62$eb4e4470$7a1335a1@zavod.tel.fer.hr>
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