Flatten the sources, only leave the XPath module packed.
[tatoo.git] / src / qName.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-10 23:05:56 CET by Kim Nguyen>
18 *)
19
20 include Hcons.Make (struct
21   include String
22   let hash s = Hashtbl.hash s
23   let equal s1 s2 = s1 = s2
24 end)
25
26 let print pp s = Format.fprintf pp "%s" s.node
27
28 let of_string = make
29 let to_string = node
30
31 let document = of_string "#document"
32 let text = of_string "#text"
33 let comment = of_string "#comment"
34 let nil = of_string "#"
35
36 let attribute t = of_string ( "@" ^ (to_string t))
37 let processing_instruction t = of_string ( "?" ^ (to_string t))
38
39 let remove_prefix t =
40   let s = to_string t in
41   let lens = String.length s in
42   if lens == 0 then t
43   else
44     if s.[0] == '@' || s.[0] == '?' then
45       of_string (String.sub s 1 (lens-1))
46     else
47       t