<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:<br><br>
</p>
<p style="margin-bottom:0cm" lang="en"> I have a trouble with
validating xml document by xsd schema in case of</p>
<p style="margin-bottom:0cm" lang="en">use comment in the xml
document. I attached simple sample, where you can see this problem.
To run it, compile xml_comment_test.erl and invoke
invalid_xml_comment_test method.</p>
<p style="margin-bottom:0cm" lang="en"> You can see the error
message:</p>
<p style="margin-bottom:0cm" lang="en">_________________________________________________________________<br>{error,
</p>
<p style="margin-bottom:0cm" lang="en"> [{"context[1]",xmerl_xsd,
</p>
<p style="margin-bottom:0cm" lang="en"> {undefined,
</p>
<p style="margin-bottom:0cm" lang="en"> {internal_error,
</p>
<p style="margin-bottom:0cm" lang="en">
{function_clause,
</p>
<p style="margin-bottom:0cm" lang="en">
[{xmerl_xsd,check_choice,
</p>
<p style="margin-bottom:0cm" lang="en">
[[{xmlComment,
</p>
<p style="margin-bottom:0cm" lang="en">
[{result,2},{rule,2},{context,1}],
</p>
<p style="margin-bottom:0cm" lang="en">
4,[],
</p>
<p style="margin-bottom:0cm" lang="en">
" continue context=\"ctx_megaco_local_in\"/ "}],
</p>
<p style="margin-bottom:0cm" lang="en">
[{element,
</p>
<p style="margin-bottom:0cm" lang="en">
{{continue,
</p>
<p style="margin-bottom:0cm" lang="en">
[anonymous,result,anonymous,rule,anonymous,
</p>
<p style="margin-bottom:0cm" lang="en">
context],
</p>
<p style="margin-bottom:0cm" lang="en">
[]},
</p>
<p style="margin-bottom:0cm" lang="en">
{1,1}}}],
</p>
<p style="margin-bottom:0cm" lang="en">
{1,1},
</p>
<p style="margin-bottom:0cm" lang="en">
['_xmerl_no_name_','_xmerl_no_name_',
</p>
<p style="margin-bottom:0cm" lang="en">
'_xmerl_no_name_'],
</p>
<p style="margin-bottom:0cm" lang="en">
{xsd_state,"ecss_routing.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">
[anonymous,result,anonymous,rule,anonymous,
</p>
<p style="margin-bottom:0cm" lang="en">
context],
</p>
<p style="margin-bottom:0cm" lang="en">
[],unqualified,unqualified,undefined,undefined,
</p>
<p style="margin-bottom:0cm" lang="en">
[{"xs",'<a href="http://www.w3.org/2001/XMLSchema'">http://www.w3.org/2001/XMLSchema'</a>},
</p>
<p style="margin-bottom:0cm" lang="en">
{"xml",'<a href="http://www.w3.org/XML/1998/namespace'}">http://www.w3.org/XML/1998/namespace'}</a>],
</p>
<p style="margin-bottom:0cm" lang="en">
[{undefined,
</p>
<p style="margin-bottom:0cm" lang="en">
[{"xs",'<a href="http://www.w3.org/2001/XMLSchema'}]}">http://www.w3.org/2001/XMLSchema'}]}</a>],
</p>
<p style="margin-bottom:0cm" lang="en">
[{"#this#","ecss_routing.xsd",undefined},
</p>
<p style="margin-bottom:0cm" lang="en">
{"xml",[],
</p>
<p style="margin-bottom:0cm" lang="en">
'<a href="http://www.w3.org/XML/1998/namespace'}">http://www.w3.org/XML/1998/namespace'}</a>],
</p>
<p style="margin-bottom:0cm" lang="en">
28690,false,false,[],[],
</p>
<p style="margin-bottom:0cm" lang="en">
#Fun<xmerl_xsd.1.36898106>,[],1,[],[],[],[],[],[],
</p>
<p style="margin-bottom:0cm" lang="en">
[],[],[]},
</p>
<p style="margin-bottom:0cm" lang="en">
[{xmlText,
</p>
<p style="margin-bottom:0cm" lang="en">
[{result,2},{rule,2},{context,1}],
</p>
<p style="margin-bottom:0cm" lang="en">
3,[],"\n ",text},
</p>
<p style="margin-bottom:0cm" lang="en">
{xmlElement,continue,continue,[],
</p>
<p style="margin-bottom:0cm" lang="en">
{xmlNamespace,[],[]},
</p>
<p style="margin-bottom:0cm" lang="en">
[{result,2},{rule,2},{context,1}],
</p>
<p style="margin-bottom:0cm" lang="en">
2,
</p>
<p style="margin-bottom:0cm" lang="en">
[{xmlAttribute,context,[],[],[],
</p>
<p style="margin-bottom:0cm" lang="en">
[{continue,2},
</p>
<p style="margin-bottom:0cm" lang="en">
{result,2},
</p>
<p style="margin-bottom:0cm" lang="en">
{rule,2},
</p>
<p style="margin-bottom:0cm" lang="en">
{context,1}],
</p>
<p style="margin-bottom:0cm" lang="en">
1,[],"ctx_megaco_local_in",false}],
</p>
<p style="margin-bottom:0cm" lang="en">
[],[],
</p>
<p style="margin-bottom:0cm" lang="en">
"/home/konstantin/erlang/tasks/diffR15B02/xml_comment_test",
</p>
<p style="margin-bottom:0cm" lang="en">
undeclared},
</p>
<p style="margin-bottom:0cm" lang="en">
{xmlText,
</p>
<p style="margin-bottom:0cm" lang="en">
[{result,2},{rule,2},{context,1}],
</p>
<p style="margin-bottom:0cm" lang="en">
1,[],"\n ",text}]],
</p>
<p style="margin-bottom:0cm" lang="en">
[{file,"xmerl_xsd.erl"},{line,2806}]},
</p>
<p style="margin-bottom:0cm" lang="en">
{xmerl_xsd,check_element_type,6,
</p>
<p style="margin-bottom:0cm" lang="en">
[{file,"xmerl_xsd.erl"},{line,2601}]},
</p>
<p style="margin-bottom:0cm" lang="en">
{xmerl_xsd,check_sequence,6,
</p>
<p style="margin-bottom:0cm" lang="en">
[{file,"xmerl_xsd.erl"},{line,2754}]},
</p>
<p style="margin-bottom:0cm" lang="en">
{xmerl_xsd,check_element_type,6,
</p>
<p style="margin-bottom:0cm" lang="en">
[{file,"xmerl_xsd.erl"},{line,2601}]},
</p>
<p style="margin-bottom:0cm" lang="en">
{xmerl_xsd,check_sequence,6,
</p>
<p style="margin-bottom:0cm" lang="en">
[{file,"xmerl_xsd.erl"},{line,2754}]},
</p>
<p style="margin-bottom:0cm" lang="en">
{xmerl_xsd,check_element_type,6,
</p>
<p style="margin-bottom:0cm" lang="en">
[{file,"xmerl_xsd.erl"},{line,2601}]},
</p>
<p style="margin-bottom:0cm" lang="en">
{xmerl_xsd,validate_xml,3,
</p>
<p style="margin-bottom:0cm" lang="en">
[{file,"xmerl_xsd.erl"},{line,2418}]},
</p>
<p style="margin-bottom:0cm" lang="en">
{xmerl_xsd,validate3,3,
</p>
<p style="margin-bottom:0cm" lang="en">
[{file,"xmerl_xsd.erl"},{line,251}]}]}}}}]}
<br>________________________________________________________________</p>
<p style="margin-bottom:0cm" lang="en"><br>
</p>
<p style="margin-bottom:0cm" lang="en">How can i see, in the
xmerl_xsd.erl module, check_choice metod. No function for processing
comments.</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.<br><br>_______________________ctx_megaco.xml____________________________<br><?
xml version =
"1.0"?><br><context><br> <rule><br> <result><br> <continue
context="ctx_megaco_local_in"/><br> <!
- Continue context = "ctx_megaco_local_in" / -><br> </
result><br> </ rule><br></
context><br>________________________________________________________________<br><br>_________________________ecss_routing.xsd__________________________<br><?
xml version = "1.0" encoding = "UTF- 8" ?
><br><xs:schema
xmlns:xs="<a href="http://www.w3.org/2001/XMLSchema">http://www.w3.org/2001/XMLSchema</a>"><br> <br> <xs:element
name="context"><br> <xs:complexType><br> <xs:sequence><br> <xs:element
name="rule"><br> <xs:complexType><br> <xs:sequence><br> <xs:element
name="result"><br> <xs:complexType><br> <xs:choice><br> <xs:element
name="incomplete" type="xs:string"/><br> <!
- xs: element name = "no_route" type = "nullType"
/ -><br> <xs:element
name="continue" type="continueType"/><br> </
xs: choice><br> </
xs: complexType><br> </
xs: element><br> </
xs: sequence><br> </
xs: complexType><br> </
xs: element><br> </ xs:
sequence><br> </ xs: complexType><br> </
xs: element><br> <br> <xs:complexType
name="continueType"><br> <xs:attribute
name="context" type="xs:string"/><br> </
xs: complexType><br></ xs:
schema><br>________________________________________________________________<br><br>_______________________xml_comment_test.erl__________________________<br><br>-module
(xml_comment_test).<br><br>-export
([<br> invalid_xml_comment_test
/ 0<br> ]).<br><br>read_xml
(FileName) -><br> {ok, Schema} = xmerl_xsd:
process_schema ("ecss_routing.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_comment_test ()
-><br> Result = read_xml
("ctx_megaco.xml"),<br> io: format
("~ p ~ n",
[Result]).<br>________________________________________________________________<br><br>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.</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">@@ -2799,12 +2799,16 @@</p>
<p style="margin-bottom:0cm" lang="en">
%%check_sequence(Seq,[],_Occ,_Env,_S,_Checked) -></p>
<p style="margin-bottom:0cm" lang="en">
%%{error,{unmatched_elements,Seq}}.</p>
<p style="margin-bottom:0cm" lang="en">
</p>
<p style="margin-bottom:0cm" lang="en">
</p>
<p style="margin-bottom:0cm" lang="en"> %% Choice one alternative
must occur unless all alternatives are</p>
<p style="margin-bottom:0cm" lang="en"> %% optional or the entire
choice is optional.</p>
<p style="margin-bottom:0cm" lang="en">+%% EltexPatch: add skip xml
comment
</p>
<p style="margin-bottom:0cm" lang="en">+check_choice([C =
#xmlComment{} |Rest],CM,Env,Block,S,Checked) -></p>
<p style="margin-bottom:0cm" lang="en">+
check_choice(Rest,CM,Env,Block,S,[C |Checked]);</p>
<p style="margin-bottom:0cm" lang="en">+</p>
<p style="margin-bottom:0cm" lang="en">
check_choice([T=#xmlText{}|Rest],Els,Occ,Env,S,Checked) -></p>
<p style="margin-bottom:0cm" lang="en"> case is_whitespace(T) of</p>
<p style="margin-bottom:0cm" lang="en"> true -></p>
<p style="margin-bottom:0cm" lang="en">
check_choice(Rest,Els,Occ,Env,S,[T|Checked]);</p>
<p style="margin-bottom:0cm" lang="en"> _ -></p>
<p style="margin-bottom:0cm" lang="en">
{error,{error_path(T,undefined),?MODULE,</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>
<p style="margin-bottom:0cm"><br>
</p>
</div>