Re: Alternatives to redefine

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