Should be simple开发者_开发问答 but I cannot find any information on this anywhere. I want to make some simple elements required, therefore invalidate the XML if some of the elements are empty. I have tried using the nillable attribute but this does not work. I have had to add limitations to the number of characters needed and then remove white space to get this working but it seems really lon winded, am I misssing something?
eg.
<xsd:element name="productImageURL">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:minLength value="1"/>
<xsd:maxLength value="450"/>
<xsd:whiteSpace value="collapse"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
It is the way it is with the XML Schema. Another option could be to use the xsd:pattern facet... Readability though is much better the way you've done it; most people struggle reading patterns such as regular expressions...
精彩评论