+(******************************************************************************)
+(* SXSI : XPath evaluator *)
+(* Kim Nguyen (Kim.Nguyen@nicta.com.au) *)
+(* Copyright NICTA 2008 *)
+(* Distributed under the terms of the LGPL (see LICENCE) *)
+(******************************************************************************)
+
+let collect_tags v =
+ let rec aux acc v =
+ if Tree.Binary.is_node v
+ then
+ let tag = Tree.Binary.tag v
+ in
+ let acc = aux (Ptset.add tag acc) (Tree.Binary.first_child v)
+ in
+ aux (Ptset.add tag acc) (Tree.Binary.next_sibling v)
+ else acc
+ in
+ aux Ptset.empty v
+;;
+
+
+if Array.length (Sys.argv) <> 2
+then
+ begin
+ Printf.printf "usage: %s file.xml\n" (Sys.argv.(0));
+ exit 1
+ end
+
+
+let doc =
+ try
+ Tree.Binary.parse_xml_uri Sys.argv.(1)
+ with
+ | _ ->
+ Printf.printf "Error parsing document\n";
+ exit 2
+;;
+let _ = Tag.init (Tree.Binary.tag_pool doc)
+;;
+let tags = (Ptset.add (Tag.tag "foo") (collect_tags doc))
+;;
+
+let _ = Tree.Binary.test_xml_tree Format.std_formatter tags doc
+;;
+