4 (* https://erratique.ch/software/xmlm/doc/Xmlm/index.html#outns *)
5 let test_ezxmlm_out () =
6 Logr.info
(fun m
-> m
"%s.%s" "xmlm_test" "text_ezxmlm_out");
9 |> Assrt.equals_string __LOC__
"";
10 [ `El
((("", "uhu"), []), []) ]
12 |> Assrt.equals_string __LOC__
"<uhu/>";
13 [ `El
((("", "e"), [ (("", "a"), "v") ]), [ `Data
"foo" ]) ]
15 |> Assrt.equals_string __LOC__
"<e a=\"v\">foo</e>";
16 [ `El
((("", "e"), [ (("", "xmlns"), "A") ]), [ `Data
"foo" ]) ]
18 |> Assrt.equals_string __LOC__
"<e xmlns=\"A\">foo</e>";
19 [ `El
((("A", "e"), [((Xmlm.ns_xmlns
, "xmlns"), "A")]), [`Data
"foo"]) ]
21 |> Assrt.equals_string __LOC__
"<e xmlns=\"A\">foo</e>";
22 [ `El
((("N", "e"), [((Xmlm.ns_xmlns
, "n"), "N")]), [`Data
"foo"]) ]
24 |> Assrt.equals_string __LOC__
"<n:e xmlns:n=\"N\">foo</n:e>";
27 let test_ezxmlm_out2() =
28 Logr.info
(fun m
-> m
"%s.%s" "xmlm_test" "text_ezxmlm_out2");
29 [`El
((("","elm"),[(("","nam"),"val")]),[])]
31 |> Assrt.equals_string __LOC__
{|<elm nam
="val"/>|};
32 [`El
((("uri 2","root"),[
33 ((Xmlm.ns_xmlns
,"n2"),"uri 2");
35 `El
((("uri 2","c1"),[
41 |> Ezxmlm.to_string ~decl
:true
42 |> Assrt.equals_string __LOC__
{|<?xml version
="1.0" encoding
="UTF-8"?
>
43 <n2
:root xmlns
:n2
="uri 2"><n2
:c1
>uhu
</n2
:c1
></n2
:root
>|};
46 let test_xmlm_signals () =
47 Logr.info
(fun m
-> m
"%s.%s" "xmlm_test" "test_xmlm_signals");
48 let dst = Buffer.create
1024 in
49 Buffer.add_string
dst {|<?xml version
="1.0" encoding
="UTF-8"?
>
51 Buffer.add_string
dst "<!-- huhu -->\n";
52 let o = Xmlm.make_output ~decl
:false ~indent
:(Some
2) (`Buffer
dst) in
53 let out = Xmlm.output
o in
55 out (`El_start
(("uri","e"),[
56 ((Xmlm.ns_xmlns
,"n"),"uri");
63 |> Assrt.equals_string __LOC__
{|<?xml version
="1.0" encoding
="UTF-8"?
>
65 <n
:e xmlns
:n
="uri" k
="v">
70 let test_xmlm_frag () =
71 Logr.info
(fun m
-> m
"%s.%s" "xmlm_test" "test_xmlm_signals");
72 let x : _
Xmlm.frag
= `El
((("uri", "e"), [
73 ((Xmlm.ns_xmlns
, "n"), "uri");
76 let dst = Buffer.create
1024 in
77 Buffer.add_string
dst {|<?xml version
="1.0" encoding
="UTF-8"?
>
79 Buffer.add_string
dst "<!-- huhu -->\n";
80 let o = Xmlm.make_output ~decl
:false ~indent
:(Some
2) (`Buffer
dst) in
81 Xmlm.output_doc_tree
(fun x -> x) o (None
,x);
85 |> Assrt.equals_string __LOC__
{|<?xml version
="1.0" encoding
="UTF-8"?
>
87 <n
:e xmlns
:n
="uri" k
="v">
93 Unix.chdir
"../../../test/";