[erlang-questions] Problem with XML validation using xmerl_xsd:validate().

Андрей Сединин sedinin@REDACTED
Fri Dec 26 00:47:44 CET 2008


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