 <p><strong>This XSD will allow your first example XML but not your second:</strong></p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"&gt; &lt;xs:element name="rule" type="RuleType"/&gt; &lt;xs:complexType name="RuleType"&gt; &lt;xs:choice&gt; &lt;xs:element name="setting" minOccurs="1" maxOccurs="unbounded" /&gt; &lt;xs:element ref="rule" minOccurs="1" maxOccurs="unbounded" /&gt; &lt;/xs:choice&gt; &lt;xs:attribute name="condition" use="required"/&gt; &lt;/xs:complexType&gt; &lt;/xs:schema&gt; </code></pre> <p><strong>Read the XSD like this:</strong> <em>Each <code>rule</code> can consist of either one or more <code>setting</code> elements or one or more other <code>rule</code> elements (recursively).</em></p>