X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Focaml%2Fxml%2Fxml.ml;h=809e11d3ffdefd355eb2d23ab4112f93de791e81;hb=9a0e4f3be9f70662f18d2d3b6dd60ae79fba565b;hp=4439fad1d41f9581f5d0f78e868931ef20226982;hpb=108f7ef287b08d4d7228790d7c6d956434f16c6c;p=helm.git diff --git a/helm/ocaml/xml/xml.ml b/helm/ocaml/xml/xml.ml index 4439fad1d..809e11d3f 100644 --- a/helm/ocaml/xml/xml.ml +++ b/helm/ocaml/xml/xml.ml @@ -101,12 +101,9 @@ let pp_to_outchan strm oc = flush oc ;; -let pp_to_outchan = - let profiler = HExtlib.profile "Xml.pp_to_outchan" in - fun strm oc -> profiler.HExtlib.profile (pp_to_outchan strm) oc - let pp_to_gzipchan strm oc = pp_gen (fun s -> Gzip.output oc s 0 (String.length s)) strm +;; (** pretty printer to string *) let pp_to_string strm = @@ -144,6 +141,12 @@ let pp ?(gzip=false) strm fn = | None -> pp_to_outchan strm stdout ;; +let pp = + let profiler = HExtlib.profile "Xml.pp" in + fun ?gzip strm fn -> + profiler.HExtlib.profile (pp ?gzip strm) fn +;; + let add_xml_declaration stream = let box_prefix = "b" in [< @@ -157,3 +160,16 @@ let add_xml_declaration stream = ] stream >] + (* TODO BRRRRR .... *) + (** strip first 4 line of a string, used to strip xml declaration and doctype + declaration from XML strings generated by Xml.pp_to_string *) +let strip_xml_headings s = + let rec aux n pos = + if n = 0 + then String.sub s pos (String.length s - pos) + else aux (n - 1) (String.index_from s pos '\n' + 1) + in + try + aux 4 0 + with Not_found -> s +