[erlang-bugs] xmerl_xsd incorrect behavior?

Alexander Demidenko alex.demidenko@REDACTED
Thu May 12 14:15:29 CEST 2011


Hello, friends!

I found two trubles with xmerl_xsd module.

When I try to validate "invalid_xml_bug.xml" by "ss.xsd" (see
attachment files), I'll get the error:

{error,
    [{"ss_list[1]/ss[4]",xmerl_xsd,
      {element_not_suitable_with_schema,
          {ssd,[ssType],[]},
          {xsd_state,"ss.xsd",
              [230908739019541468279786040419060913848],
              false,".",[],
              [ssType],
              [],qualified,unqualified,undefined,undefined,
              [{"xs",'http://www.w3.org/2001/XMLSchema'},
               {"xml",'http://www.w3.org/XML/1998/namespace'}],
              [{undefined,[{"xs",'http://www.w3.org/2001/XMLSchema'}]}],
              [{"#this#","ss.xsd",undefined},
               {"xml",[],'http://www.w3.org/XML/1998/namespace'}],
              16400,false,false,[],[],#Fun<xmerl_xsd.0.103136280>,[],2,[],[],
              [],[],[],[],[],[],[]}}},
     {"ss_list[1]/ss[4]",xmerl_xsd,
      {element_not_suitable_with_schema,
          {csd,[ssType],[]},
          {xsd_state,"ss.xsd",
              [230908739019541468279786040419060913848],
              false,".",[],
              [ssType],
              [],qualified,unqualified,undefined,undefined,
              [{"xs",'http://www.w3.org/2001/XMLSchema'},
               {"xml",'http://www.w3.org/XML/1998/namespace'}],
              [{undefined,[{"xs",'http://www.w3.org/2001/XMLSchema'}]}],
              [{"#this#","ss.xsd",undefined},
               {"xml",[],'http://www.w3.org/XML/1998/namespace'}],
              16400,false,false,[],[],#Fun<xmerl_xsd.0.103136280>,[],2,[],[],
              [],[],[],[],[],[],
              [{"ss_list[1]/ss[4]",xmerl_xsd,
                {element_not_suitable_with_schema,
                    {ssd,[ssType],[]},
                    {xsd_state,"ss.xsd",
                        [230908739019541468279786040419060913848],
                        false,".",[],
                        [ssType],
                        [],qualified,unqualified,undefined,undefined,
                        [{"xs",'http://www.w3.org/2001/XMLSchema'},
                         {"xml",'http://www.w3.org/XML/1998/namespace'}],
                        [{undefined,
                             [{"xs",'http://www.w3.org/2001/XMLSchema'}]}],
                        [{"#this#","ss.xsd",undefined},
                         {"xml",[],'http://www.w3.org/XML/1998/namespace'}],
                        16400,false,false,[],[],#Fun<xmerl_xsd.0.103136280>,
                        [],2,[],[],[],[],[],[],[],[],[]}}}]}}}]}

But, as I know, this xml absolutly correct.

Second problem is big memory eating. (depends of counts <ss> tag
inside of <ss_list>)
When I try to validate "memory_leak_bug.xml" by "ss.xsd" my
application hang, and memory usage begin increasing.

To show this two problems I've wrote "xml_test" module with two
methods "invalid_xml_test", "memory_leak_xml_test".

-module(xml_test).
-export([invalid_xml_test/0, memory_leak_xml_test/0]).

read_xml(FileName) ->
    {ok, Schema} = xmerl_xsd:process_schema("ss.xsd"),
    {ok, BXml} = file:read_file(FileName),
    Xml = erlang:binary_to_list(BXml),
    {XmerXml, _} = xmerl_scan:string(Xml),
    xmerl_xsd:validate(XmerXml, Schema).

invalid_xml_test() ->
    Result = read_xml("invalid_xml_bug.xml"),
    io:format("~p~n", [Result]).

memory_leak_xml_test() ->
    Result = read_xml("memory_leak_bug.xml"),
    io:format("~p~n", [Result]).


Tested by Erlang 13B4, xmerl 1.2.4 and 14B2, xmerl 1.2.8

-- 
---------------------------------------------
With best regards,
Alexander.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: XMerlBug.tar.gz
Type: application/x-gzip
Size: 2328 bytes
Desc: not available
URL: <http://erlang.org/pipermail/erlang-bugs/attachments/20110512/8e36d8d5/attachment.bin>


More information about the erlang-bugs mailing list