[erlang-bugs] bug_xmerl_attributeGroup

Константин Маликов kostiamalikov@REDACTED
Tue Oct 29 05:05:36 CET 2013


Hello , friends. I want to tell you about a bug in Erlang:


 I have a trouble with scaning xsd document in case of use attributeGroup
in the xsd document. I attached simple sample, where you can see this
problem. To run it, compile xml_group_test.erl and invoke
“invalid_xml_group_test” method.

You can see the error message:
_________________________________________________________________
** exception error: no match of right hand side value {error,

[{[],xmerl_xsd,

{internal_error,merge_derived_types,

{function_clause,

[{xmerl_xsd,extend_attributes,

[[],

[{attributeGroup,{attributeGroup,[],[]}},

{attribute,{example1,['Type'],[]}}],

{core,[],[]},

[],deduce,

{xsd_state,"ivr.xsd",

[93547814522301227513625523114529142023],

false,false,".",[],[],...}],

[{file,"xmerl_xsd.erl"},{line,4358}]},

{xmerl_xsd,merge_derived_types2,5,

[{file,"xmerl_xsd.erl"},{line,4041}]},

{xmerl_xsd,merge_derived_types,5,

[{file,"xmerl_xsd.erl"},{line,4011}]},

{xmerl_xsd,deduce_derived_type2,3,

[{file,"xmerl_xsd.erl"},{line,4576}]},

{xmerl_xsd,deduce_derived_types,2,

[{file,"xmerl_xsd.erl"},{line,4544}]},

{xmerl_xsd,process_schema2,3,

[{file,"xmerl_xsd.erl"},{line,315}]},

{dbg_debugged,reply,1,

[{file,"dbg_debugged.erl"},{line,103}]},

{dbg_debugged,handle_command,1,

[{file,"dbg_debugged.erl"},{line,96}]}]}}}]}

in function xml_group_test:read_xml/1 (xml_group_test.erl, line 7)

in call from xml_group_test:invalid_xml_group_test/0 (xml_group_test.erl,
line 18)
________________________________________________________________

 How can i see, in the xmerl_xsd.erl module, extended_attributes metod. No
function for processing attributeGroup.


 Tested by Erlang 16B02, xmerl 1.3.4 and R15B02, xmerl 1.3.2


 _______________________group.xml____________________________
<? xml version = "1.0" encoding = "utf- 8" ? >
<dialog example1="str1234"> </ dialog>
________________________________________________________________

_________________________ivr.xsd__________________________
<? xml version = "1.0" encoding = "UTF- 8" ? >
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">

<xsd:element name="dialog" type="Type"/>

<xsd:complexType name="Type">
<xsd:complexContent>
<xsd:extension base="core">
<xsd:attributeGroup ref="attributeGroup"/>
<xsd:attribute name="example1" type="xsd:string"/>
</ xsd: extension>
</ xsd: complexContent>
</ xsd: complexType>

<xsd:complexType name="core">
</ xsd: complexType>

<xsd:attributeGroup name="attributeGroup">
</ xsd: attributeGroup>

</ xsd: schema>
________________________________________________________________

_______________________xml_group_test.erl__________________________
-module (xml_group_test).

-export ([invalid_xml_group_test / 0 ]).

read_xml (FileName) ->
    {ok, Schema} = xmerl_xsd: process_schema ("ivr.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_group_test () ->
    Result = read_xml ("group.xml"),
    io: format ("~ p ~ n", [Result]).
________________________________________________________________

I can offer the option of a patch that fixes this problem. The person who
is responsible for supporting ssh has the discretion to take it as it is,
or can make own fix.

________________________________________________________________

--- xmerl-1.3.2/src/xmerl_xsd.erl 2013-10-26 14:25:25.000000000

+++ xmerl-1.3.2.1/src/xmerl_xsd.erl 2013-10-26 13:01:03.000000000

@@ -4350,17 +4354,24 @@

check_element_presence2(Name,[E|BCM],Acc) ->

check_element_presence2(Name,BCM,[E|Acc]);

check_element_presence2(_Name,[],_Acc) ->

error.

 %% A check of the extended attribute should take place here.

-%%

extend_attributes(BaseAtts,[EA={attribute,Name}|ExtAtts],

BaseTypeName,CM,Mode,S) ->

NewAtts=key_replace_or_insert(Name,2,BaseAtts,EA),

extend_attributes(NewAtts,ExtAtts,BaseTypeName,CM,Mode,S);

+

+%% EltexPatch: support attributeGroup

+extend_attributes(BaseAtts,[{attributeGroup,Name}|ExtAtts],

+ BaseTypeName,CM,Mode,S) ->

+ {#schema_attribute_group{content = AGAttributes}, S2} =
load_object({attributeGroup, Name}, S),

+ NewAtts=lists:foldl(fun({attribute,{AttrName, _, _}}, AttrIn) ->
key_replace_or_insert(AttrName,2,AttrIn,{attribute, AttrName}); (_, AttrIn)
-> AttrIn end, BaseAtts, AGAttributes),

+ extend_attributes(NewAtts,ExtAtts,BaseTypeName,CM,Mode,S2);

+

%% Extension of wildcards should be handled as described in chapter

%% 3.4.2 and subsection "Complex Type Definition with simple content

%% Schema Component".

extend_attributes(BaseAtts,[LocalWC={anyAttribute,_NS_PC}|ExtAtts],

BaseTypeName,CM,deduce,S) ->

{CompleteWC,S2} = complete_wildcard(LocalWC,CM,S),

________________________________________________________________


 With best regards,

Malikov Constantin, software developer, Eltex.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-bugs/attachments/20131029/af11dd70/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: xml_attributeGroup.tar.gz
Type: application/x-gzip
Size: 28134 bytes
Desc: not available
URL: <http://erlang.org/pipermail/erlang-bugs/attachments/20131029/af11dd70/attachment.bin>


More information about the erlang-bugs mailing list