M
mstilli
Hi,
I am trying to use schema for server side validation using xerces to
catch the validation errors.
validating this XML:
<Content4>
<textarea13></textarea13>
<binaryobject3></binaryobject3>
</Content4>
against this schema:
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsd:element name="Content4" type="contentType"/>
<xsd:complexType name="contentType">
<xsd:sequence>
<xsd:element minOccurs="0" name="metainfo" type="metainfo"/>
<xsd:element minOccurs="1" name="text16" type="text16"/>
<xsd:element name="textarea13" type="textarea13"/>
<xsd:element minOccurs="0" name="binaryobject3"
type="binaryobject3"/>
</xsd:sequence>
</xsd:complexType>
<xsd:simpleType name="text16">
<xsd:restriction base="xsd:string"/>
</xsd:simpleType>
<xsd:simpleType name="textarea13">
<xsd:restriction base="xsd:string">
<xsd:minLength value="1"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:complexType name="binaryobject3">
<xsd:attribute name="filename"/>
</xsd:complexType>
<xsd:complexType name="metainfo">
<xsd:sequence>
<xsd:any maxOccurs="unbounded" minOccurs="0"
processContents="skip"/>
</xsd:sequence>
<xsd:anyAttribute processContents="skip"/>
</xsd:complexType>
</xsd:schema>
output these messages:
cvc-complex-type.2.4.a: Invalid content was found starting with
element 'textarea13'.
One of '{metainfo, text16}' is expected.
-------------^
This message seems to me a little wrong, given
<xsd:element minOccurs="0" name="metainfo" type="metainfo"/>
----------------------------------------^
Perhaps I'm missing something, but as far as I understood, if this
atribute value is set to 0 the element is *optional*, thus can't figure
why xerces doesn't discriminate and report "one of those is expected".
I would expect it to report only about the mandatory element(s)
missing, and not the whole sequence...
I googled this but found nothing. Am I missing something?
The other messages are just as expected...
cvc-minLength-valid: Value '' with length = '0' is not facet-valid with
respect to minLength '1' for type 'textarea13'.
cvc-type.3.1.3: The value '' of element 'textarea13' is not valid.
Thanks
marcello stillitano
I am trying to use schema for server side validation using xerces to
catch the validation errors.
validating this XML:
<Content4>
<textarea13></textarea13>
<binaryobject3></binaryobject3>
</Content4>
against this schema:
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsd:element name="Content4" type="contentType"/>
<xsd:complexType name="contentType">
<xsd:sequence>
<xsd:element minOccurs="0" name="metainfo" type="metainfo"/>
<xsd:element minOccurs="1" name="text16" type="text16"/>
<xsd:element name="textarea13" type="textarea13"/>
<xsd:element minOccurs="0" name="binaryobject3"
type="binaryobject3"/>
</xsd:sequence>
</xsd:complexType>
<xsd:simpleType name="text16">
<xsd:restriction base="xsd:string"/>
</xsd:simpleType>
<xsd:simpleType name="textarea13">
<xsd:restriction base="xsd:string">
<xsd:minLength value="1"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:complexType name="binaryobject3">
<xsd:attribute name="filename"/>
</xsd:complexType>
<xsd:complexType name="metainfo">
<xsd:sequence>
<xsd:any maxOccurs="unbounded" minOccurs="0"
processContents="skip"/>
</xsd:sequence>
<xsd:anyAttribute processContents="skip"/>
</xsd:complexType>
</xsd:schema>
output these messages:
cvc-complex-type.2.4.a: Invalid content was found starting with
element 'textarea13'.
One of '{metainfo, text16}' is expected.
-------------^
This message seems to me a little wrong, given
<xsd:element minOccurs="0" name="metainfo" type="metainfo"/>
----------------------------------------^
Perhaps I'm missing something, but as far as I understood, if this
atribute value is set to 0 the element is *optional*, thus can't figure
why xerces doesn't discriminate and report "one of those is expected".
I would expect it to report only about the mandatory element(s)
missing, and not the whole sequence...
I googled this but found nothing. Am I missing something?
The other messages are just as expected...
cvc-minLength-valid: Value '' with length = '0' is not facet-valid with
respect to minLength '1' for type 'textarea13'.
cvc-type.3.1.3: The value '' of element 'textarea13' is not valid.
Thanks
marcello stillitano