gtaborga
gtaborga

Reputation: 833

Can an XSD schema contain another XSD's content inside it?

To elaborate on the title of this question, what I have is a main schema that defines the structure of my XML. However, the XML files are being used in a manner similar to the following:

<!DOCTYPE root [
    <!ENTITY node1 SYSTEM "C:\node1.xml">
    <!ENTITY node2 SYSTEM "C:\node2.xml">
]>
<root>
    &node1;
    &node2;
</root>

For this reason, I want to be able to define a schema that represents these individual "nodes". This would allow me to have intellisense for both the top-level root xml and for each of the sub-level node xml files.

Is it possible to define a schema XSD that references another XSD's content as its own? I want to avoid having to duplicate the same schema definitions that are in the node.xsd within the root.xsd, while providing intellisense for the someone creating a root.xml, or a node.xml.

Please let me know if I need to clarify. Thanks for your help.

Upvotes: 4

Views: 579

Answers (1)

Mads Hansen
Mads Hansen

Reputation: 66781

Yes, it is possible to include other schema's structure and definitions into your schema.

You can use <xsd:import> or <xsd:include> to incorporate other Schemas into yours.

Depending on the namespaces, how restrictive the other Schema(s) are, etc. you may have some issues doing so.

Upvotes: 3

Related Questions