[erlang-questions] Problem with XML validation using xmerl_xsd:validate().
Lian Cheng
rhythm.mail@REDACTED
Mon Dec 29 14:56:27 CET 2008
Hi,
Your schema suggests that the "status" element should have a text value
among "Valid", "Invalid" and "", while in your XML snippet, the "status"
element has no text value, rather than have a text value of an empty
string. I think that the difference between <status></status> and
<status/> just like, in the C language, the difference between:
char* p = NULL;
and
char* p = "";
In a word, <status></status> is not equivalent to <status/> in your
situation, although I'm not quite sure about my opinion :-)
Cheers
Cheng
Андрей Сединин 写道:
> Hello
>
> Please help to sort it out:
>
> trying to validate XML using:
>
> {ok, State } = xmerl_xsd:process_schema("test.xsd"),
> {Entity ,_} = xmerl_scan:file("test.xml"),
> xmerl_xsd:validate(Entity, State).
>
>
> XSD content:
>
> <?xml version="1.0" encoding="UTF-8"?>
>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
> elementFormDefault="qualified" attributeFormDefault="unqualified">
>
> <xs:element name="status">
> <xs:complexType>
> <xs:simpleContent>
> <xs:extension base="status-type"/>
> </xs:simpleContent>
> </xs:complexType>
> </xs:element>
> <xs:simpleType name="status-type">
> <xs:restriction base="xs:string">
> <xs:enumeration value="Valid" />
> <xs:enumeration value="Invalid" />
> <xs:enumeration value="" />
> </xs:restriction>
> </xs:simpleType>
> </xs:schema>
> and receive next error:
>
> XML content:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <status/>
>
>
> Got an error:
>
> {error,[{[],xmerl_xsd,
> {empty_content_not_allowed,[{enumeration,"Valid"},
> {enumeration,"Invalid"},
> {enumeration,[]}]}}]}
>
>
> I think it is valid markup for this schema. The same opinion has some
> other validating parsers.
>
> How do you think?
>
> --
> Sedinin
>
>
>
More information about the erlang-questions
mailing list