[erlang-bugs] xmerl, xmerl_scan, trouble with validating xml document with attribute containse "
Alexander Demidenko
alex.demidenko@REDACTED
Wed Jun 29 07:16:33 CEST 2011
Hello,
I have a trouble with validating xml document by xsd schema in case of
one of the attribute in the xml document containse " in own
value. I attached simple sample, where you can see this problem. To
run it, compile xml_test and invoke "test" method.
You can see the error message:
{error,[{value_not_string,["\"",85,110,115,117,112,112,111,114,116,101,100,32,113,117,111,116,32,104,101,114,101,33,"\""]}]}.
How can I see, the problem in the xmerl_scan.erl module,
scan_att_chars method. In case of using " value in the
attribute's value, this metod return nonflatten value of the
attribute.
Tested by Erlang 13B4, xmerl 1.2.4 and 14B3, xmerl 1.2.9
%% file test.xml
<?xml version="1.0" encoding="UTF-8"?>
<in xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
xs:noNamespaceSchemaLocation="test.xsd" name=""Unsupported quot
here!""/>
%% file test.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:spec="rps.xsd">
<xs:element name="in">
<xs:complexType>
<xs:attribute name="name" type="xs:string"
use="required"></xs:attribute>
</xs:complexType>
</xs:element>
</xs:schema>
%% file test.erl
-module(xml_test).
-export([
test/0
]).
read_xml(FileName) ->
{ok, Schema} = xmerl_xsd:process_schema("test.xsd"),
{ok, BXml} = file:read_file(FileName),
Xml = erlang:binary_to_list(BXml),
{XmerXml, _} = xmerl_scan:string(Xml),
xmerl_xsd:validate(XmerXml, Schema).
test() ->
try
Result = read_xml("test.xml"),
io:format("~p~n", [Result])
catch
_: Error ->
io:format("Error: ~p", [Error])
end.
--
---------------------------------------------
With best regards,
Alexander.
More information about the erlang-bugs
mailing list