W3C home > Mailing lists > Public > xmlschema-dev@w3.org > June 2001

Re: multiple type definitions for elements with the same name

From: Kohsuke KAWAGUCHI <kohsukekawaguchi@yahoo.com>
Date: Thu, 07 Jun 2001 13:20:30 -0700
To: "Noel Bush" <noel@alicebot.org>
Cc: xmlschema-dev@w3.org
Message-Id: <20010607090136.48D2.KOHSUKEKAWAGUCHI@yahoo.com>

(Jeff Rafter wrote)
> I don't think you can do exactly what you want-- much of what you are
> looking for includes co-constraints (if attribute x, then element y).
> Co-constraints can be expressed using a tool like Schematron in conjunction

While I agree that Noel can't get what he wants, (she? I'm sorry. I'm
not good at telling the gender from the name..),  the problem is not
because of the so-called "co-constraints".


But I think XML Schema can be abused to better model Noel's language.
How about this?

<!-- make it a "ur-type" and abstract -->
<simpleType name="conditionType" abstract="true" />

<complexType name="conditionType.single">
  <simpleContent>
    <extension base="conditionType">
      <attribute name="gender" ... />
    </restriction>
  </simpleContent>
</complexType>

<complexType name="conditionType.list">
  <complexContent>
    <extension base="conditionType">
      <sequence>
        <!-- use local element declaration so that you can define
              li for different purposes later -->
        <element name="li" maxOccurs="unbounded">
          <complexType>
            <simpleContent>
              <extension base="string">
                <attribute name="gender" ... />
                <attribute name="name" ... />
              </extension>
            </simpleContent>
          </complexType>
        </element>
      </sequence>
    </extension>
  </complexContent>
</complexType>

.. and so on...

<element name="condition">
  <complexType ref="conditionType"/>
</element>

But certainly you can't capture the "default list condition".


Also, you may want to check out different languages like RELAX, TREX, or
RELAX NG. Things like this are as easy as ABC.


regards,
----------------------
K.Kawaguchi
E-Mail: kohsukekawaguchi@yahoo.com
Received on Thursday, 7 June 2001 16:20:46 GMT

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