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

Re: Alternatives to redefine

From: Jeni Tennison <jeni@jenitennison.com>
Date: Mon, 8 Jul 2002 23:44:08 +0100
Message-ID: <37212399694.20020708234408@jenitennison.com>
To: xmlschema-dev@w3.org, "Bowden Wise" <wiseb@acm.org>

Hi Bowden,

> I am developing a schema that must be extensible for different
> applications/purposes. One sub-tree of the schema is the variable
> part. A <results> node may contain a sequence of other elements but
> the "other" elements is what varies from one appplication to the
> next.
>
> For example, one application may have results of type:
>   A, B, C
> while another applicaiton has
>   A, D, E
>
> <results> nodes may appear several times within an instance
> but a <results> node always has a sequence of one of the
> above allowable types (they are never mixed)
>
> e.g., 
> <results><A/><A/></results>
> <results><C/></results>
>
> are valid but
> <results><A/><B/><B/></results>
> is not
>
> I am trying to define a basic schema and enable each applicaiton to
> extend it in order to define the allowable result types.

Hmm... What about having:

<xs:element name="results">
  <xs:complexType>
    <xs:group ref="resultsContent" />
  </xs:complexType>
</xs:element>

<xs:group name="resultsContent">
  <xs:sequence />
</xs:group>

and then, in the application schemas, redefining the group
resultsContent, for example with:

<xs:redefine schemaLocation="base.xsd">

<xs:group name="resultsContent">
  <xs:sequence>
    <xs:group ref="resultsContent" />
    <xs:choice>
      <xs:element name="A" maxOccurs="unbounded" />
      <xs:element name="B" maxOccurs="unbounded" />
      <xs:element name="C" maxOccurs="unbounded" />
    </xs:choice>
  </xs:sequence>
</xs:group>

</xs:redefine>

Note that you have to refer to the base 'resultsContent' group in the
redefinition, despite the fact that it doesn't contain anything,
because redefinitions of model groups have to be either extensions or
restrictions of the original model group, and if you don't refer to
the group itself, the validator will assume you're trying to create a
restriction.

> The other requirement I have is I want to be able to use Castor to
> generate corresponding java classes. When I tried using
> <xsd:redefine> I discovered that Castor does not pick up the
> substitution groups correctly.

I have no idea whether Castor will use the above properly -- let us
know!

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/
Received on Monday, 8 July 2002 18:44:10 UTC

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