40

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.

abatishchev
  • 98,240
  • 88
  • 296
  • 433
Robert Gould
  • 68,773
  • 61
  • 187
  • 272

2 Answers2

60

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.

maxdev
  • 2,491
  • 1
  • 25
  • 50
jdmichal
  • 10,984
  • 4
  • 43
  • 42
5

Use the <include> element, see for example here.

Rahul Sharma
  • 5,614
  • 10
  • 57
  • 91
David Norman
  • 19,396
  • 12
  • 64
  • 54