X-Git-Url: http://git.nguyen.vg/gitweb/?p=tatoo.git;a=blobdiff_plain;f=src%2FqName.ml;fp=src%2FqName.ml;h=4a3aac4a312c99768673d417a1350f81425d563e;hp=0000000000000000000000000000000000000000;hb=b00bff88c7902e828804c06b7f9dc55222fdc84e;hpb=03b6a364e7240ca827585e7baff225a0aaa33bc6 diff --git a/src/qName.ml b/src/qName.ml new file mode 100644 index 0000000..4a3aac4 --- /dev/null +++ b/src/qName.ml @@ -0,0 +1,47 @@ +(***********************************************************************) +(* *) +(* TAToo *) +(* *) +(* Kim Nguyen, LRI UMR8623 *) +(* Université Paris-Sud & CNRS *) +(* *) +(* Copyright 2010-2012 Université Paris-Sud and Centre National de la *) +(* Recherche Scientifique. All rights reserved. This file is *) +(* distributed under the terms of the GNU Lesser General Public *) +(* License, with the special exception on linking described in file *) +(* ../LICENSE. *) +(* *) +(***********************************************************************) + +(* + Time-stamp: +*) + +include Hcons.Make (struct + include String + let hash s = Hashtbl.hash s + let equal s1 s2 = s1 = s2 +end) + +let print pp s = Format.fprintf pp "%s" s.node + +let of_string = make +let to_string = node + +let document = of_string "#document" +let text = of_string "#text" +let comment = of_string "#comment" +let nil = of_string "#" + +let attribute t = of_string ( "@" ^ (to_string t)) +let processing_instruction t = of_string ( "?" ^ (to_string t)) + +let remove_prefix t = + let s = to_string t in + let lens = String.length s in + if lens == 0 then t + else + if s.[0] == '@' || s.[0] == '?' then + of_string (String.sub s 1 (lens-1)) + else + t