[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [Elist Home]
Subject: Re: combine
There's an important aspect of derivation by extension that this does not
capture.
Suppose I have a schema for invoice that has shippingAddress and
invoiceAddress elements, and suppose that the content of these types is
declared to be the complex type Address. If I have understood XML Schema
correctly, once you derive UKAddress from Address you are allowed to do
<shippingAddress xsi:type="UKAddress">
...
<postCode>W8 6UT</postCode>
</shippingAddress>
In other words, deriving from Address changes what is allowed by a reference
to Address.
Personally, I abhor xsi:type, but I think the functionality it is providing
is useful. Given a schema like this:
<define name="Address">
...
</define>
<start>
<element name="invoice">
<element name="shippingAddress">
<ref name="Address"/>
</element>
<element name="invoiceAddress">
<ref name="Address"/>
</element>
...
</element>
</start>
the requirement is to be able to create a schema in which addresses also
allow a postCode. Derivation by extension in XML Schema supports this. In
RELAX NG, combine="group" provides similar functionality.
<grammar>
<include href="invoice.rng"/>
<define name="Address" combine="group">
<element name="postCode">
<text/>
</element>
</define>
</grammar>
> We do not need "combine" for mimicking "derivation by extension".
> Here is a rewrite of an example of "derivation by extension" in
> XML Schema Part 0.
>
> <grammar>
>
> <start>
> <element name="dmy">
> <element name="uk">
> <ref name="UKAddress"/>
> </element>
> <element name="us">
> <ref name="USAddress"/>
> </element>
> </element>
> </start>
>
> <define name="Address">
> <element name="name"><anyString/></element>
> <element name="street"><anyString/></element>
> <element name="city"><anyString/></element>
> </define>
>
> <define name="USAddress">
> <ref name="Address"/>
> <element name="state"><anyString/></element>
> <element name="zip"><anyString/></element>
> </define>
>
> <define name="UKAddress">
> <ref name="Address"/>
> <element name="postcode"><anyString/></element>
> <attribute name="exportCode"><anyString/></attribute>
> </define>
>
> </grammar>
>
> Cheers,
>
> Makoto
>
>
>
[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [Elist Home]
Powered by eList eXpress LLC