Reputation: 14126
I am presently reading Professional XML by Bill Evjen, Kent Sharkey, Thiru Thangarathinam, Michael Kay, Alessandro Vernet, Sam Ferguson.
I am a beginner and trying to get the basic structure of the XML Schema document. The authors put forward the concepts on how to put XML Schema Documents together.
import
Imports allow you to import another entire XML Schema document into the one that you are already working with. This is usually done if the two varying XML Schema documents utilize different namespaces. This import is done using the
<import>
element and two attributes—namespace andschemaLocation
.
include
The
<include>
element is used if the other schema has the same namespace or makes use of no namespace. It is quite similar to the<import>
element and is a good way to combine two schemas with little work.
I find myself really confused with line, the include element is used if the other schema has the same namespace or makes use of no namespace.
If they have the same namespace, wouldn't it results in clash between the same elements defined in both schemas?
Upvotes: 1
Views: 232
Reputation: 111501
If you're combining XSDs from the same namespace or no namespace via xsd:include
, yes, there could be naming clashes, but when you choose to use xsd:include
typically you have control over both XSDs and can avoid clashes.
It's when you're combining XSD from disparate sources, often not under your control, that having separate namespaces is more needed to avoid component name clashes.
See also What's the difference between xsd:include and xsd:import?
Upvotes: 2