Let’s say I have an XML element like this, and I’m trying to write the XSD for this element:
<foo name="bar">
...
</foo>
The rules for this element are:
- Its name is “foo”
- It has an attribute with name “bar”
- Its “bar” attribute value is a string
- It must have one or more children
This XSD encapsulate all of the rules except the last:
How do I specify the last rule—that the element must have children?
Use the
<xs:any>element to allow any elements as child content.Example code to match your rules:
You can control the allowed elements and the validation of foo’s children by using
namespaceandprocessContentsattributes with that<xs:any>element.