Fixed string_trim, updated xmlm.ml
This commit is contained in:
parent
26647cdbd3
commit
a69d4ee835
4
cpdf.ml
4
cpdf.ml
|
@ -3227,8 +3227,8 @@ let rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||||
(* For OCaml < 4.00 *)
|
(* For OCaml < 4.00 *)
|
||||||
let string_trim s =
|
let string_trim s =
|
||||||
implode
|
implode
|
||||||
(dropwhile
|
(rev (dropwhile
|
||||||
Pdf.is_whitespace (rev (dropwhile Pdf.is_whitespace (explode s))))
|
Pdf.is_whitespace (rev (dropwhile Pdf.is_whitespace (explode s)))))
|
||||||
|
|
||||||
let combine_with_spaces strs =
|
let combine_with_spaces strs =
|
||||||
string_trim
|
string_trim
|
||||||
|
|
72
xmlm.ml
72
xmlm.ml
|
@ -1,7 +1,7 @@
|
||||||
(*---------------------------------------------------------------------------
|
(*---------------------------------------------------------------------------
|
||||||
Copyright 2007 Daniel C. Bünzli. All rights reserved.
|
Copyright (c) 2007 Daniel C. Bünzli. All rights reserved.
|
||||||
Distributed under a BSD3 license, see license at the end of the file.
|
Distributed under the ISC license, see terms at the end of the file.
|
||||||
%%NAME%% release %%VERSION%%
|
%%NAME%% %%VERSION%%
|
||||||
---------------------------------------------------------------------------*)
|
---------------------------------------------------------------------------*)
|
||||||
|
|
||||||
module Std_string = String
|
module Std_string = String
|
||||||
|
@ -961,7 +961,7 @@ struct
|
||||||
let make_output ?(decl = true) ?(nl = false) ?(indent = None)
|
let make_output ?(decl = true) ?(nl = false) ?(indent = None)
|
||||||
?(ns_prefix = fun _ ->None) d =
|
?(ns_prefix = fun _ ->None) d =
|
||||||
let outs, outc = match d with
|
let outs, outc = match d with
|
||||||
| `Channel c -> (output c), (output_char c)
|
| `Channel c -> (output_substring c), (output_char c)
|
||||||
| `Buffer b -> (Std_buffer.add_substring b), (Std_buffer.add_char b)
|
| `Buffer b -> (Std_buffer.add_substring b), (Std_buffer.add_char b)
|
||||||
| `Fun f ->
|
| `Fun f ->
|
||||||
let os s p l =
|
let os s p l =
|
||||||
|
@ -1173,35 +1173,43 @@ end
|
||||||
|
|
||||||
include Make(String) (Buffer)
|
include Make(String) (Buffer)
|
||||||
|
|
||||||
|
(* Pretty printers *)
|
||||||
|
|
||||||
|
let pp = Format.fprintf
|
||||||
|
let rec pp_list ?(pp_sep = Format.pp_print_cut) pp_v ppf = function
|
||||||
|
| [] -> ()
|
||||||
|
| v :: vs ->
|
||||||
|
pp_v ppf v; if vs <> [] then (pp_sep ppf (); pp_list ~pp_sep pp_v ppf vs)
|
||||||
|
|
||||||
|
let pp_name ppf (p, l) = if p <> "" then pp ppf "%s:%s" p l else pp ppf "%s" l
|
||||||
|
let pp_attribute ppf (n, v) = pp ppf "@[<1>(%a,@,%S)@]" pp_name n v
|
||||||
|
let pp_tag ppf (name, atts) =
|
||||||
|
let pp_sep ppf () = pp ppf ";@ " in
|
||||||
|
pp ppf "@[<1>(%a,@,@[<1>[%a]@])@]"
|
||||||
|
pp_name name (pp_list ~pp_sep pp_attribute) atts
|
||||||
|
|
||||||
|
let pp_dtd ppf = function
|
||||||
|
| None -> pp ppf "None"
|
||||||
|
| Some dtd -> pp ppf "@[<1>(Some@ %S)@]" dtd
|
||||||
|
|
||||||
|
let pp_signal ppf = function
|
||||||
|
| `Data s -> pp ppf "@[`Data %S@]" s
|
||||||
|
| `El_end -> pp ppf "`El_end"
|
||||||
|
| `El_start tag -> pp ppf "@[`El_start %a@]" pp_tag tag
|
||||||
|
| `Dtd dtd -> pp ppf "@[`Dtd %a@]" pp_dtd dtd
|
||||||
|
|
||||||
(*----------------------------------------------------------------------------
|
(*----------------------------------------------------------------------------
|
||||||
Copyright 2007 Daniel C. Bünzli
|
Copyright (c) 2007 Daniel C. Bünzli
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Permission to use, copy, modify, and/or distribute this software for any
|
||||||
modification, are permitted provided that the following conditions are
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
met:
|
copyright notice and this permission notice appear in all copies.
|
||||||
|
|
||||||
1. Redistributions of source code must retain the above copyright
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
notice, this list of conditions and the following disclaimer.
|
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
2. Redistributions in binary form must reproduce the above copyright
|
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
notice, this list of conditions and the following disclaimer in the
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
documentation and/or other materials provided with the
|
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
distribution.
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
|
||||||
3. Neither the name of Daniel C. Bünzli nor the names of
|
|
||||||
contributors may be used to endorse or promote products derived
|
|
||||||
from this software without specific prior written permission.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
||||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
||||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
||||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
||||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
||||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
---------------------------------------------------------------------------*)
|
---------------------------------------------------------------------------*)
|
||||||
|
|
Loading…
Reference in New Issue