W3C home > Mailing lists > Public > www-xml-schema-comments@w3.org > April to June 2000

Re: general schema and subschema's

From: Henry S. Thompson <ht@cogsci.ed.ac.uk>
Date: 18 May 2000 10:27:36 +0100
To: David <david-v@dds.nl>
Cc: www-xml-schema-comments@w3.org
Message-ID: <f5b3dngb43b.fsf@cogsci.ed.ac.uk>
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

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 23:08:47 UTC