Pages

Wednesday, February 22, 2012

Share XML Schema modules with xsd:include

You can share XML Schema modules with other XML Schemas by using the xsd:include element. An example would be sharing a "common elements" Schema (e.g., defines paragraphs, titles, lists, and so forth) that can be reused across multiple Schemas.

To include the commonelements.xsd in your current Schema, simply add the xsd:include element like so:

xmlns="http://www.mydoc.org/schema" targetNamespace="http://www.mydoc.org/schema">

Note the xsd:include must be a top level element and appear at the beginning of the Schema. Also, the targetNamespace attribute on the current Schema shows where the included Schema is found.

Now, any elements in the commonelements.xsd can be referenced in the content model of elements in the current Schema.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.