Re: general schema and subschema's

David <david-v@dds.nl> writes:

> hi,
> 
> I need to write an XML schema (Starting with the latest draft and 
> updating as soon as it is a recommendation) thas has the common elements 
> and attributes used in my XML files. Since there is a need to include 
> more elements than the ones specified in the general schema (some 
> companies want to be able to include companyspecific elements) I was 
> wondering what the possibilities are of having one general schema and a 
> few smaller schema's. 
> 
> Is the use of namespaces the right way of implementing this? are there 
> parsers that will validate an XML when using more than one schema?

Yes, and yes.

Basic paradigm: write one master schema document for your namespace.
In you master schema, leave
  <any namespace='##other' processContents='strict' minOccurs='0'/>
placeholders in your content models where company-specific material is 
allowed.  Assign a new namespace to any company-specific extensions,
and write a schema for just that extension.  If necessary, it can
<import> the master namespace to hand back over.  Then a compliant
schema-validator, e.g. XSV [1], will do the right thing.

Example document:

<master:root xmlns:master="http://www.example.com/Master"
             xmlns:cse="http://www.example.org/CompanySpecific"
             xsi:schemaLocation="http://www.example.com/Master
                                   http://www.example.com/schemas/Master.xsd
                                 http://www.example.org/CompanySpecific
                                   http://www.example.com/schemas/CS1.xsd">
  <master:envelop ...>
    ....
    <cse:localRoot ...>
      ...
       <master:nugget...>...</master:nugget>
      ...
    </cse:localRoot>
    ...
  </master:envelop>

Master.xsd has that <any ...> above in various places
CS1.xsd has

 <schema ... xmlns:master="http://www.example.com/Master"...>

   <import namespace="http://www.example.com/Master"/>

and somewhere inside some content model(s):

   <element ref="master:nugget"/>

Hope this helps,

ht

[1] http://cgi.w3.org/cgi-bin/xmlschema-check
-- 
  Henry S. Thompson, HCRC Language Technology Group, University of Edinburgh
          W3C Fellow 1999--2001, part-time member of W3C Team
     2 Buccleuch Place, Edinburgh EH8 9LW, SCOTLAND -- (44) 131 650-4440
	    Fax: (44) 131 650-4587, e-mail: ht@cogsci.ed.ac.uk
		     URL: http://www.ltg.ed.ac.uk/~ht/

Received on Thursday, 18 May 2000 05:27:40 UTC