I have two XSDs that are definining different documents. Say A.xsd
defines an element ElementA
as the root, with some complex rules. Now B.xsd
defines an element ElementB
that is supposed to use ElementA
somewhere in between.
For example I want the XML file for ElementB
look like this:
<?xml version="1.0" encoding="utf-8"?>
<ElementB xmlns="http://example.com/namespace/for/ElementB">
<foo>Bla</foo>
<bar>Blub</bar>
<ElementA xmlns="http://example.com/namespace/for/ElementA">
<!-- ... -->
</ElementA>
</ElementB>
Then B.xsd
could look like this:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns="http://example.com/namespace/for/ElementB" targetNamespace="http://example.com/namespace/for/ElementB" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xs:element name="ElementB">
<xs:complexType>
<xs:sequence>
<xs:element name="foo" type="xs:string" />
<xs:element name="bar" type="xs:string" />
<!-- And now I want to include ElementA somehow -->
<xs:element name="ElementA" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
The thing is that I don‘t really want to clone the specification of ElementA
into B.xsd
, as there are also documents, that just have ElementA
as the root (i.e. ElementB
is some kind of container document).
So, how can I allow ElementA
within ElementB
while completely building on top of the already existent XSD?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…