Re: include the same schema file more than once

Hi Steve,

> Suppose an XML Schema uses <xs:include> to include other schema files.
> (These in turn may also include schema files.)
> As a result, some schema files might be included more than once. 
>
> Q1. Is this valid according to the XML Schema specification?

Yes. See the note at the end of Section 4.2.1 of the XML Schema Rec
(http://www.w3.org/TR/xmlschema-1/#compound-schema), which says:

  NOTE: The above is carefully worded so that multiple <include>ing of
  the same schema document will not constitute a violation of clause 2
  of Schema Properties Correct (§3.15.6), but applications are
  allowed, indeed encouraged, to avoid <include>ing the same schema
  document more than once to forestall the necessity of establishing
  identity component by component.

> Q3. Is anyone aware of a tool that will "expand" a schema?
> This tool would process all the include (and ideally also import)
> statements in a schema, producing a single schema file as output
> that has no redundant includes and no redundant type definitions.

You can't resolve imports since XML Schema's XML syntax is
specifically designed such that each namespace must be described in a
different document. You could resolve includes using XSLT, though it's
not particularly straight-forward given that you need to avoid
circular includes and provide for the fact that imports/redefinitions
have to come first in the schema (which necessitates two passes over
the include tree)...

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/

Received on Saturday, 17 July 2004 05:36:58 UTC