W3C home > Mailing lists > Public > xmlschema-dev@w3.org > December 2001

Re: How to refer to another Schema from a Schema?

From: Jeni Tennison <jeni@jenitennison.com>
Date: Wed, 19 Dec 2001 19:04:23 +0000
Message-ID: <6327343287.20011219190423@jenitennison.com>
To: Shweta Sinha <shwet_sam@yahoo.com>
CC: xmlschema-dev@w3.org
Hi Shweta,

> I would like to know how to create a generic schema doc which will
> be referred to by all my other schema documents in the namespace?
> Say I have atag called Error:
> </ERROR>
> this node / tag has to be included in all my schemas. Instead of
> adding to each schema I want have a separate doc containing just
> this tag & referred to by all the other schema docs.

No problem. Declare the ERROR element as a global element in one
schema, then include that schema into your other schemas with

<xs:include schemaLocation="error.xsd" />

You can then refer to the declaration of the ERROR element in just the
same way as you would if it were declared in the including schema.

If the various schemas that you need to use the ERROR element within
are all in different namespaces, then you should have no target
namespace in the shared schema. The shared schema will then 'adopt'
the target namespace of the schema in which you include it. If they're
all in the same namespace, I think it's better practice to make sure
that the target namespace of the shared schema is the same as the
ones in which it's used.

See http://www.w3.org/TR/xmlschema-0/#SchemaInMultDocs for an example.



Jeni Tennison
Received on Wednesday, 19 December 2001 14:04:25 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 23:14:56 UTC