aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnthony Ramine <[email protected]>2010-12-07 23:31:34 +0100
committerLars Thorsen <[email protected]>2011-11-11 11:58:43 +0100
commit6d841684ff63ff8cc6295ea4c4461385ab594136 (patch)
treec53c7bd780ff6208a13d4868d78a6f270536849d
parentfcf6b58a1f7a2eafa0db79f1715db1c193c3f346 (diff)
downloadotp-6d841684ff63ff8cc6295ea4c4461385ab594136.tar.gz
otp-6d841684ff63ff8cc6295ea4c4461385ab594136.tar.bz2
otp-6d841684ff63ff8cc6295ea4c4461385ab594136.zip
Accumulate comments in element nodes
-rw-r--r--lib/xmerl/src/xmerl_scan.erl7
-rw-r--r--lib/xmerl/src/xmerl_xpath.erl6
-rw-r--r--lib/xmerl/src/xmerl_xpath_pred.erl3
3 files changed, 13 insertions, 3 deletions
diff --git a/lib/xmerl/src/xmerl_scan.erl b/lib/xmerl/src/xmerl_scan.erl
index 9e3e6ee728..5f61fe2bb1 100644
--- a/lib/xmerl/src/xmerl_scan.erl
+++ b/lib/xmerl/src/xmerl_scan.erl
@@ -2553,9 +2553,6 @@ scan_content("&" ++ T, S0, Pos, Name, Attrs, Space, Lang, Parents, NS, Acc,[]) -
_ ->
scan_content(string_to_char_set(S1#xmerl_scanner.encoding,ExpRef)++T1,S1,Pos,Name,Attrs,Space,Lang,Parents,NS,Acc,[])
end;
-scan_content("<!--" ++ T, S, Pos, Name, Attrs, Space, Lang, Parents, NS, Acc,[]) ->
- {_, T1, S1} = scan_comment(T, S, Pos, Parents, Lang),
- scan_content(T1, S1, Pos+1, Name, Attrs, Space, Lang, Parents, NS, Acc,[]);
scan_content("<" ++ T, S0, Pos, Name, Attrs, Space, Lang, Parents, NS, Acc,[]) ->
?bump_col(1),
{Markup, T1, S1} =
@@ -2615,6 +2612,10 @@ scan_content_markup("![CDATA[" ++ T, S0, Pos, _Name, _Attrs,
scan_content_markup("?"++T,S0,Pos,_Name,_Attrs,_Space,_Lang,Parents,_NS) ->
?bump_col(1),
scan_pi(T, S, Pos, Parents);
+scan_content_markup("!--" ++ T, S0, Pos, _Name, _Attrs,
+ _Space, Lang, Parents, _NS) ->
+ ?bump_col(1),
+ scan_comment(T, S, Pos, Parents, Lang);
scan_content_markup(T, S, Pos, _Name, _Attrs, Space, Lang, Parents, NS) ->
scan_element(T, S, Pos, Space, Lang, Parents, NS).
diff --git a/lib/xmerl/src/xmerl_xpath.erl b/lib/xmerl/src/xmerl_xpath.erl
index db3d3ac2d6..ee06f08029 100644
--- a/lib/xmerl/src/xmerl_xpath.erl
+++ b/lib/xmerl/src/xmerl_xpath.erl
@@ -303,6 +303,9 @@ write_node(#xmlNode{pos = Pos,
node = #xmlText{value = Txt,
parents = Ps}}) ->
{text, Pos, Txt, Ps};
+write_node(#xmlNode{pos = Pos,
+ node = #xmlComment{parents = Ps}}) ->
+ {comment, Pos, '', Ps};
write_node(_) ->
other.
@@ -628,6 +631,7 @@ node_type(#xmlElement{}) -> element;
node_type(#xmlText{}) -> text;
node_type(#xmlPI{}) -> processing_instruction;
node_type(#xmlNamespace{}) -> namespace;
+node_type(#xmlComment{}) -> comment;
node_type(#xmlDocument{}) -> root_node.
%% "The namespace axis contains the namespace nodes of the context node;
@@ -730,6 +734,8 @@ node_test({node_type, NT}, #xmlNode{node = N}, _Context) ->
true;
{namespace, #xmlNamespace{}} ->
true;
+ {comment, #xmlComment{}} ->
+ true;
_ ->
false
end;
diff --git a/lib/xmerl/src/xmerl_xpath_pred.erl b/lib/xmerl/src/xmerl_xpath_pred.erl
index 451a09bee3..9ad7925111 100644
--- a/lib/xmerl/src/xmerl_xpath_pred.erl
+++ b/lib/xmerl/src/xmerl_xpath_pred.erl
@@ -442,6 +442,9 @@ string_value(El=#xmlNode{type=element}) ->
string_value(T=#xmlNode{type=text}) ->
#xmlText{value=Txt} = T#xmlNode.node,
?string(Txt);
+string_value(T=#xmlNode{type=comment}) ->
+ #xmlComment{value=Txt} = T#xmlNode.node,
+ ?string(Txt);
string_value(infinity) -> ?string("Infinity");
string_value(neg_infinity) -> ?string("-Infinity");
string_value(A) when is_atom(A) ->