I'm trying to create an XML Schema to validate the following xml structure.
<ul>
<li>123
<ul>
<li>A</li>
<li>B</li>
<li>C</li>
</ul>
</li>
</ul>
I would like it to fail if the "123" text content is missing or is only white space.
The following schema is as far as I have got. It insists on exactly 3 non-empty list elements.
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="ul">
<xs:complexType>
<xs:sequence>
<xs:element name="li">
<xs:complexType mixed="true">
<xs:sequence>
<xs:element name="ul">
<xs:complexType>
<xs:sequence>
<xs:element type="nonEmptyString" name="li" maxOccurs="3" minOccurs="3" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:simpleType name="nonEmptyString">
<xs:restriction base="xs:string">
<xs:minLength value="1"/>
<xs:pattern value="(\s*[^\s]\s*)+"></xs:pattern>
</xs:restriction>
</xs:simpleType>
</xs:schema>
I'm guessing from In XML Schema, can mixed content restrict the type of the text? that this probably isn't possible but I thought I would ask anyway in case there was a workaround.