<div dir="ltr">


        
        
        
        <style type="text/css">P { margin-bottom: 0.21cm; }</style>


<p style="margin-bottom:0cm" lang="en">       Hello , friends. I want to
tell you about a bug in Erlang:</p>
<p style="margin-bottom:0cm" lang="en"><br>
</p>
<p style="margin-bottom:0cm" lang="en">       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.</p>
<p style="margin-bottom:0cm" lang="en">       You can see the error
message:<br>_________________________________________________________________<br>**
exception error: no match of right hand side value {error, 
</p>
<p style="margin-bottom:0cm" lang="en">                             
                         [{[],xmerl_xsd, 
</p>
<p style="margin-bottom:0cm" lang="en">                             
                           {internal_error,merge_derived_types, 
</p>
<p style="margin-bottom:0cm" lang="en">                             
                            {function_clause, 
</p>
<p style="margin-bottom:0cm" lang="en">                             
                             [{xmerl_xsd,extend_attributes, 
</p>
<p style="margin-bottom:0cm" lang="en">                             
                               [[], 
</p>
<p style="margin-bottom:0cm" lang="en">                             
                               
[{attributeGroup,{attributeGroup,[],[]}}, 
</p>
<p style="margin-bottom:0cm" lang="en">                             
                                 {attribute,{example1,['Type'],[]}}],
</p>
<p style="margin-bottom:0cm" lang="en">                             
                                {core,[],[]}, 
</p>
<p style="margin-bottom:0cm" lang="en">                             
                                [],deduce, 
</p>
<p style="margin-bottom:0cm" lang="en">                             
                                {xsd_state,"ivr.xsd", 
</p>
<p style="margin-bottom:0cm" lang="en">                             
                                
[93547814522301227513625523114529142023], 
</p>
<p style="margin-bottom:0cm" lang="en">                             
                                 false,false,".",[],[],...}],
</p>
<p style="margin-bottom:0cm" lang="en">                             
                               [{file,"xmerl_xsd.erl"},{line,4358}]},
</p>
<p style="margin-bottom:0cm" lang="en">                             
                              {xmerl_xsd,merge_derived_types2,5, 
</p>
<p style="margin-bottom:0cm" lang="en">                             
                               [{file,"xmerl_xsd.erl"},{line,4041}]},
</p>
<p style="margin-bottom:0cm" lang="en">                             
                              {xmerl_xsd,merge_derived_types,5, 
</p>
<p style="margin-bottom:0cm" lang="en">                             
                               [{file,"xmerl_xsd.erl"},{line,4011}]},
</p>
<p style="margin-bottom:0cm" lang="en">                             
                              {xmerl_xsd,deduce_derived_type2,3, 
</p>
<p style="margin-bottom:0cm" lang="en">                             
                               [{file,"xmerl_xsd.erl"},{line,4576}]},
</p>
<p style="margin-bottom:0cm" lang="en">                             
                              {xmerl_xsd,deduce_derived_types,2, 
</p>
<p style="margin-bottom:0cm" lang="en">                             
                               [{file,"xmerl_xsd.erl"},{line,4544}]},
</p>
<p style="margin-bottom:0cm" lang="en">                             
                              {xmerl_xsd,process_schema2,3, 
</p>
<p style="margin-bottom:0cm" lang="en">                             
                               [{file,"xmerl_xsd.erl"},{line,315}]},
</p>
<p style="margin-bottom:0cm" lang="en">                             
                              {dbg_debugged,reply,1, 
</p>
<p style="margin-bottom:0cm" lang="en">                             
                              
[{file,"dbg_debugged.erl"},{line,103}]}, 
</p>
<p style="margin-bottom:0cm" lang="en">                             
                              {dbg_debugged,handle_command,1, 
</p>
<p style="margin-bottom:0cm" lang="en">                             
                              
[{file,"dbg_debugged.erl"},{line,96}]}]}}}]} 
</p>
<p style="margin-bottom:0cm" lang="en">     in function 
xml_group_test:read_xml/1 (xml_group_test.erl, line 7) 
</p>
<p style="margin-bottom:0cm" lang="en">     in call from
xml_group_test:invalid_xml_group_test/0 (xml_group_test.erl, line 18)
<br>________________________________________________________________<br><br>
</p>
<p style="margin-bottom:0cm" lang="en">How can i see, in  the
xmerl_xsd.erl module, extended_attributes metod. No function for
processing attributeGroup.</p>
<p style="margin-bottom:0cm" lang="en"><br>
</p>
<p style="margin-bottom:0cm" lang="en">Tested by Erlang 16B02, xmerl
1.3.4 and R15B02, xmerl 1.3.2</p>
<p style="margin-bottom:0cm" lang="en"><br>
</p>
<p style="margin-bottom:0cm"><span lang="en">_______________________group.xml____________________________<br><?
xml version = "1.0" encoding = "utf- 8" ?
><br><dialog example1="str1234"> </
dialog><br>________________________________________________________________<br><br>_________________________ivr.xsd__________________________<br><?
xml version = "1.0" encoding = "UTF- 8" ?
><br><xsd:schema
xmlns:xsd="<a href="http://www.w3.org/2001/XMLSchema">http://www.w3.org/2001/XMLSchema</a>"><br><br><xsd:element
name="dialog" type="Type"/><br><br><xsd:complexType
name="Type"><br><xsd:complexContent><br><xsd:extension
base="core"><br><xsd:attributeGroup
ref="attributeGroup"/><br><xsd:attribute
name="example1" type="xsd:string"/><br></
xsd: extension><br></ xsd: complexContent><br></ xsd:
complexType><br><br><xsd:complexType name="core"><br></
xsd: complexType><br><br><xsd:attributeGroup
name="attributeGroup"><br></ xsd: attributeGroup><br><br></
xsd:
schema><br>________________________________________________________________<br><br>_______________________xml_group_test.erl__________________________<br>-module
(xml_group_test).<br><br>-export ([invalid_xml_group_test / 0
]).<br><br>read_xml (FileName) -><br>    {ok,
Schema} = xmerl_xsd: process_schema ("ivr.xsd"),<br>    {ok,
BXml} = file: read_file (FileName),<br>    Xml =
erlang: binary_to_list (BXml),<br>    {XmerXml,
_} = xmerl_scan: string (Xml),<br>    xmerl_xsd:
validate (XmerXml, Schema).<br><br>invalid_xml_group_test ()
-><br>    Result = read_xml
("group.xml"),<br>    io: format ("~
p ~ n",
[Result]).<br>________________________________________________________________<br><br></span><span lang="en">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.</span></p>
<p style="margin-bottom:0cm" lang="en">________________________________________________________________</p>
<p style="margin-bottom:0cm" lang="en">---
xmerl-1.3.2/src/xmerl_xsd.erl   2013-10-26 14:25:25.000000000 
</p>
<p style="margin-bottom:0cm" lang="en">+++
xmerl-1.3.2.1/src/xmerl_xsd.erl 2013-10-26 13:01:03.000000000 
</p>
<p style="margin-bottom:0cm" lang="en">@@ -4350,17 +4354,24 @@ 
</p>
<p style="margin-bottom:0cm" lang="en">
check_element_presence2(Name,[E|BCM],Acc) -> 
</p>
<p style="margin-bottom:0cm" lang="en">    
check_element_presence2(Name,BCM,[E|Acc]); 
</p>
<p style="margin-bottom:0cm" lang="en">
check_element_presence2(_Name,[],_Acc) -> 
</p>
<p style="margin-bottom:0cm" lang="en">     error. 
</p>
<p style="margin-bottom:0cm" lang="en"> 
</p>
<p style="margin-bottom:0cm" lang="en"> %% A check of the extended
attribute should take place here. 
</p>
<p style="margin-bottom:0cm" lang="en">-%% 
</p>
<p style="margin-bottom:0cm" lang="en">
extend_attributes(BaseAtts,[EA={attribute,Name}|ExtAtts], 
</p>
<p style="margin-bottom:0cm" lang="en">                 BaseTypeName,CM,Mode,S)
-> 
</p>
<p style="margin-bottom:0cm" lang="en">    
NewAtts=key_replace_or_insert(Name,2,BaseAtts,EA), 
</p>
<p style="margin-bottom:0cm" lang="en">    
extend_attributes(NewAtts,ExtAtts,BaseTypeName,CM,Mode,S); 
</p>
<p style="margin-bottom:0cm" lang="en">+ 
</p>
<p style="margin-bottom:0cm" lang="en">+%% EltexPatch: support
attributeGroup 
</p>
<p style="margin-bottom:0cm" lang="en">+extend_attributes(BaseAtts,[{attributeGroup,Name}|ExtAtts],
</p>
<p style="margin-bottom:0cm" lang="en">+                BaseTypeName,CM,Mode,S)
-> 
</p>
<p style="margin-bottom:0cm" lang="en">+   
{#schema_attribute_group{content = AGAttributes}, S2} =
load_object({attributeGroup, Name}, S), 
</p>
<p style="margin-bottom:0cm" lang="en">+   
NewAtts=lists:foldl(fun({attribute,{AttrName, _, _}}, AttrIn) ->
key_replace_or_insert(AttrName,2,AttrIn,{attribute, AttrName}); (_,
AttrIn) -> AttrIn end, BaseAtts,  AGAttributes), 
</p>
<p style="margin-bottom:0cm" lang="en">+   
extend_attributes(NewAtts,ExtAtts,BaseTypeName,CM,Mode,S2); 
</p>
<p style="margin-bottom:0cm" lang="en">+ 
</p>
<p style="margin-bottom:0cm" lang="en"> %% Extension of wildcards
should be handled as described in chapter 
</p>
<p style="margin-bottom:0cm" lang="en"> %% 3.4.2 and subsection
"Complex Type Definition with simple content 
</p>
<p style="margin-bottom:0cm" lang="en"> %% Schema Component". 
</p>
<p style="margin-bottom:0cm" lang="en">
extend_attributes(BaseAtts,[LocalWC={anyAttribute,_NS_PC}|ExtAtts], 
</p>
<p style="margin-bottom:0cm" lang="en">                
BaseTypeName,CM,deduce,S) -> 
</p>
<p style="margin-bottom:0cm" lang="en">     {CompleteWC,S2} =
complete_wildcard(LocalWC,CM,S),</p>
<p style="margin-bottom:0cm" lang="en">________________________________________________________________</p>
<p style="margin-bottom:0cm" lang="en"><br>
</p>
<p style="margin-bottom:0cm"><span lang="en">With best regards</span><span lang="en">,</span></p>
<p style="margin-bottom:0cm" lang="en">Malikov Constantin, software
developer, Eltex.</p>

</div>