Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I have one XML Schema (XSD) include another XML-Schema?

Tags:

include

xml

xsd

I currently have two XSD schemes and one is a "light" version of the other. Right now I have everything in the "light" version repeated in the "complete" schema, but this becomes a pain when I need to make a change, and it goes against the DRY principle anyways, so I was wondering if there was an element that served to include another schema into a schema, so I can have my "complete" inherit from the "light" schema to reduce maintenance hurdles.

like image 605
Robert Gould Avatar asked Dec 02 '08 01:12

Robert Gould


People also ask

How do I import schema from one schema to another in XSD?

In the Imports dialog box, in the Import New Schema as list, select XSD Import, XSD Include, or XSD Redefine, as appropriate, and then click Add. In the BizTalk Type Picker dialog box, expand the Schema node in the project tree, select the schema that you want to import, include, or redefine, and then click OK.

Can XML have multiple schemas?

Deal with multiple XML schemas A restriction on the XML schema import is that only one XML schema can be loaded as source or target schema. If you want to load multiple XML schemas, please create a schema including or importing the XML schemas you want to combine.

How do I add one XSD to another?

xsd" /> where 'res' is a folder where the XSD is residing and this folder is at the same level of the folder from where you are referencing it. If you are giving Absolute path, then you need to write <xs:include schemaLocation="file:D:/workspace/Test/res/header.


1 Answers

There are two methods for this.

<xsd:include schemaLocation="pathToFile" /> should be used for including files of the same namespace.

<xsd:import namespace="namespace" schemaLocation="pathToFile" /> should be used for include files in a different namespace. Usually you will specify the namespace given as the targetNamespace of the imported schema.

like image 159
jdmichal Avatar answered Oct 21 '22 18:10

jdmichal