Reputation: 977
I want to create an XSD schema in which only the root element and its immediate child is policed by the XSD. In other words I want to allow arbitrary grand-children of the root element while root element and children elements are strictly validated by the XSD. So if I have
<text>
<language>
...
</language>
</text>
It should enforce the presence of text and language but impose no restriction what sort of XML tags I add below the level of .
Is that possible at all? I have used XSD but not to great extent and cannot find a reference, neither stating I can do it, nor that it is forbidden to do so.
Upvotes: 1
Views: 646
Reputation: 111726
Use xsd:any at the grandchild level:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
version="1.0">
<xs:element name="text">
<xs:complexType>
<xs:sequence>
<xs:element name="language">
<xs:complexType>
<xs:sequence>
<xs:any/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Other considerations:
minOccurs
and maxOccurs
) per
your needs.mixed="true"
for mixed content (text and elements) per your
needs.Upvotes: 4