1 (***********************************************************************)
5 (* Kim Nguyen, LRI UMR8623 *)
6 (* Université Paris-Sud & CNRS *)
8 (* Copyright 2010-2012 Université Paris-Sud and Centre National de la *)
9 (* Recherche Scientifique. All rights reserved. This file is *)
10 (* distributed under the terms of the GNU Lesser General Public *)
11 (* License, with the special exception on linking described in file *)
14 (***********************************************************************)
17 (** use: xml_file "XPath querie"
18 or : xml_file -f XPath_querie_file
19 only the first line of XPath_querie_file is read
25 let fd = open_in Sys.argv.(1) in
26 let d = Tree.load_xml_file fd in
28 fprintf err_formatter "Parse Tree OK ! ";
33 let arg2 = Sys.argv.(2) in
35 then let fq = open_in Sys.argv.(3) in
36 let q = XPath.parse_file fq in
38 fprintf err_formatter "Parse query OK ! ";
40 else let q = XPath.parse_string arg2 in
41 fprintf err_formatter "Parse query OK ! ";
44 let build_asta query =
45 let asta = Compil.trans query in
46 fprintf err_formatter "Compil OK ! ";
49 let compute_run doc query =
50 let run = Run.compute doc query in
51 fprintf err_formatter "Run OK ! \n";
55 let query = query () in
57 let asta = build_asta query in
58 let run = compute_run doc asta in
59 fprintf err_formatter "@[<v 0>##### Query #####@. %a@]\n"
60 XPath.Ast.print query;
61 output_string stderr "\n##### Doc #####\n";
62 Tree.print_xml stderr doc (Tree.root doc);
63 output_string stderr "\n";
64 Asta.print err_formatter asta;
65 fprintf err_formatter "@[<v 0>##### Run #####@. %a@]\n"