Yes, xs:any
will allow any elements beneath root
and will not allow mixed content:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="root">
<xs:complexType>
<xs:sequence>
<xs:any namespace="##any" processContents="lax"
minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
If you also wanted to allow mixed content, you would add mixed="true"
to xs:complexType
.
See also processContents strict vs lax vs skip for xsd:any.
Update to address comment:
How about the child nodes of those directly under the ? And all
further children down the tree? The default mixed="false" would apply
to those too?
No, the above XSD wouldn't prevent mixed content in children of root
.
To prevent mixed content deeper in the tree, you could use `processContents="strict" and preclude mixed content in the allowed elements. If this is too restrictive, in XSD 1.1 you could use an assertion:
XSD 1.1
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:vc="http://www.w3.org/2007/XMLSchema-versioning" vc:minVersion="1.1">
<xs:element name="root">
<xs:complexType>
<xs:sequence>
<xs:any namespace="##any" processContents="lax"
minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:assert test="every $e in .//*
satisfies not($e/* and $e/text()[normalize-space()])"/>
</xs:complexType>
</xs:element>
</xs:schema>