2dd1caee3d6e1ee1c1d445f9664c7508981b36d9
[tatoo.git] / src / test.ml
1 (***********************************************************************)
2 (*                                                                     *)
3 (*                               TAToo                                 *)
4 (*                                                                     *)
5 (*                     Kim Nguyen, LRI UMR8623                         *)
6 (*                   Université Paris-Sud & CNRS                       *)
7 (*                                                                     *)
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   *)
12 (*  ../LICENSE.                                                        *)
13 (*                                                                     *)
14 (***********************************************************************)
15
16 (*
17   Time-stamp: <Last modified on 2013-03-04 16:38:27 CET by Kim Nguyen>
18 *)
19
20 (** use: xml_file "XPath querie"
21     or : xml_file -f XPath_querie_file
22     only the first line of XPath_querie_file is read 
23 *)
24
25 module F = Auto.Formula
26 module A = Auto.Ata
27 module X = Xpath.Compile
28
29 (* to force ocaml build to add Formula to the dependency chain even if
30    we don't use it yet*)
31
32 let doc =
33   let fd = open_in Sys.argv.(1) in
34   let d = Tree.Naive.load_xml_file fd in
35   close_in fd; d
36
37
38 let query =
39   let arg2 = Sys.argv.(2) in
40   Xpath.Parser.parse (Ulexing.from_latin1_string arg2)
41
42 let auto =
43   Xpath.Compile.path query
44
45 open Format
46
47 let () =
48   fprintf err_formatter "Query: %a\n%!" Xpath.Ast.print_path query;
49   fprintf err_formatter "Automata: %a\n%!" Auto.Ata.print auto;
50   fprintf err_formatter "Document:\n%!";
51   Tree.Naive.print_xml stderr doc (Tree.Naive.root doc);
52   exit 0
53