W3C home > Mailing lists > Public > xmlschema-dev@w3.org > August 2007

Re: Maintaining a subset of a schema

From: Boris Kolpackov <boris@codesynthesis.com>
Date: Fri, 3 Aug 2007 09:30:54 +0200
To: Andy Den Tandt <andydt@enfocus.be>
Cc: xmlschema-dev@w3.org
Message-ID: <20070803073054.GB20630@karelia>

Hi Andy,

Andy Den Tandt <andydt@enfocus.be> writes:

> <a u='0'>
>    <b v='1'>
>        <c w='2'/>
>    </b>
> </a>
>
> and the same but without the a/b@v attribute
> <a u='0'>
>    <b>
>        <c w='2'/>
>    </b>
> </a>
>
> The c-element can be shared. It's obvious that b is a separate type. But
> the type for a also needs to change!

I don't think there is a way to achieve what you want without
syntactic changes to your XML documents except for maintaining
two separate schemas (perhaps you can factor out and reuse some
common types that are the same for both vocabularies). Or maybe
you could use the redefine construct (I personally prefer to
stay away from that beast).

If you are willing to change your XML vocabulary then you can
can use XML Schema polymorphism (either xsi:type or substitution
groups). You would define a base type for the 'b' element (say,
b_base_t) which does not contain the 'v' attribute. Then you would
define b_t by adding the 'v' attribute to b_base_t. Using the
xsi:type approach your first XML document would look like this:

<a u='0'>
   <b v='1' xsi:type="b_t">
       <c w='2'/>
   </b>
</a>

With substitution groups you can embed the type information into
element names, e.g.:

<a u='0'>
   <b v='1'>
       <c w='2'/>
   </b>
</a>

<a u='0'>
   <basic_b>
       <c w='2'/>
   </basic_b>
</a>


hth,
-boris

-- 
Boris Kolpackov
Code Synthesis Tools CC
http://www.codesynthesis.com
Open-Source, Cross-Platform C++ XML Data Binding
Received on Friday, 3 August 2007 07:32:44 GMT

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