Add a specific prefix for QNames that represent attributes.
[tatoo.git] / src / utils / 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-02-14 16:14:44 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 cdata_section = of_string "#cdata-section"
34 let comment = of_string "#comment"
35 let document_fragment = of_string "#document-fragment"
36 let attribute_map = of_string "#attribute-map"
37 let nil = of_string "#"
38 let attribute_prefix = of_string "@"
39 let has_attribute_prefix s =
40   let s = node s in
41   String.length s > 0 && s.[0] = '@'
42
43 let add_attribute_prefix s =
44   of_string ("@" ^ (node s))