I have an XSD file in which I would like to place several diagrams, with a description of the services. When adding
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"
attributeFormDefault="qualified"
targetNamespace="[target1]"
xmlns:tns="[target1]">
</xsd:schema>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"
attributeFormDefault="qualified"
targetNamespace="[target2]"
xmlns:tns="[target2]">
</xsd:schema>
I get error: "Multiple root tags"
If I write like this:
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"
attributeFormDefault="qualified"
targetNamespace="[target1]"
xmlns:tns="[target1]">
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"
attributeFormDefault="qualified"
targetNamespace="[target2]"
xmlns:tns="[target2]">
</xsd:schema>
</xsd:schema>
I get error:
Invalid content was found starting with element '{"http://www.w3.org/2001/XMLSchema":schema}'. One of '{"http://www.w3.org/2001/XMLSchema":simpleType, "http://www.w3.org/2001/XMLSchema":complexType, "http://www.w3.org/2001/XMLSchema":group, "http://www.w3.org/2001/XMLSchema":attributeGroup, "http://www.w3.org/2001/XMLSchema":element, "http://www.w3.org/2001/XMLSchema":attribute, "http://www.w3.org/2001/XMLSchema":notation, "http://www.w3.org/2001/XMLSchema":annotation}' is expected.
Is it possible to configure an XSD file to consist of multiple schemas xsd:schema
?
CodePudding user response:
XSDs cannot be composed by embedding xsd:schema
elements like that.
To incorporate multiple XSDs with distinct targetNamespace
s, use xsd:import
.
See also
- How to reference element in other XSD's namespace?
- What's the difference between xsd:include and xsd:import?
CodePudding user response:
You are only allowed to have one schema, but this schema can declare several elements suitable as root, and underneath those you could have completely disjunct tree structures.