How to restrict an element to be non-empty through xsd

The only tool you have is the xs:string pattern restriction as in below. CDATA is just an alternative to escaping with entity references. You should use entity references in your pattern.

<simpleType name="NewType2">
    <restriction base="string">
        <minLength value="5"></minLength>
        <maxLength value="30"></maxLength>
        <pattern value="(&lt;html&gt;).*(&lt;/html&gt;)"></pattern>
    </restriction>
</simpleType>

Leave a Comment