0

here's an algorithm that summarizes the possible case for using import or include.

suppose A.xsd and B.xsd two files;

  • if (targetNamesapce attribute is not defined in the two files OR defined in both with the same value (same namespace)) {use the include element;}
  • else {use the import element}

what is your opinion about this algorithm? valid or not?

thank you in advance

C. M. Sperberg-McQueen
  • 24,596
  • 5
  • 38
  • 65
Kachna
  • 2,921
  • 2
  • 20
  • 34
  • [**Here**](http://stackoverflow.com/a/23116023/290085) is a more succinct statement of when to use `xsd:import` vs `xsd:include`. – kjhughes Nov 27 '14 at 02:08

1 Answers1

1

These rules will produce correct results, but they also rule out one legal case, typically called 'chameleon include':

  • if A.xsd has a target namespace and B.xsd has none, A.xsd can include B.xsd, and B.xsd will be processed as if it had the same target namespace as A.xsd.

Note that if C.xsd also has a (different) target namespace and also include B.xsd, then the resulting schema will have some components in namespace A and some in namespace C which are derived from the same declarations in B.xsd. (Hence the name 'chameleon include': the components derived from B.xsd take on the namespace of their caller, the way a chameleon takes on the color of its surroundings.)

C. M. Sperberg-McQueen
  • 24,596
  • 5
  • 38
  • 65