1 exception NoOpenNonEmptyElements
4 Leaf of Xml.token Stream.t
5 | Node of string * (string * string) list * sectionTree list ref
8 let rec token_stream_of_section_tree_list =
11 [< token_stream_of_section_tree_list tl; token_stream_of_section_tree he >]
13 and token_stream_of_section_tree =
16 | Node (elem_name, attr_list, section_tree) ->
17 Xml.xml_nempty elem_name attr_list
18 (token_stream_of_section_tree_list !section_tree)
21 let section_stack = ref [];;
22 let xmloutput = ref (ref []);;
23 let filename = ref "";;
25 let reset_output fname =
32 let xmloutput = !xmloutput in
33 xmloutput := (Leaf n) :: !xmloutput
36 let open_non_empty_element elem_name attr_list =
37 let newxmloutput = ref [] in
38 !xmloutput := (Node (elem_name, attr_list, newxmloutput)) :: !(!xmloutput) ;
39 section_stack := !xmloutput :: !section_stack ;
40 xmloutput := newxmloutput
43 let close_non_empty_element () =
44 match !section_stack with
45 oldxmloutput::oldsection_stack ->
46 xmloutput := oldxmloutput ;
47 section_stack := oldsection_stack
48 | _ -> raise NoOpenNonEmptyElements
52 Xml.pp (token_stream_of_section_tree_list !(!xmloutput)) (Some !filename)