Commit 7121a7e3 authored by Pietro Abate's avatar Pietro Abate
Browse files

[r2003-11-24 16:00:48 by szach] - added namespace support for vrecord and get_fields

- added some comments

Original author: szach
Date: 2003-11-24 16:00:49+00:00
parent 8496896f
......@@ -27,22 +27,12 @@ let vtrue = Atom (Atoms.V.mk_ascii "true")
let vfalse = Atom (Atoms.V.mk_ascii "false")
let vbool x = if x then vtrue else vfalse
(* TODO: namespaces for the two following functions *)
let vrecord l =
let l = List.map (fun (l,v) -> LabelPool.mk (Ns.empty, U.mk l), v) l in
let l = List.map (fun (qname,v) -> LabelPool.mk qname, v) l in
Record (LabelMap.from_list_disj l)
let get_fields = function
| Record map ->
LabelMap.mapi_to_list
(fun k v -> Utf8.to_string (snd (LabelPool.value k)), v)
map
| Record map -> LabelMap.mapi_to_list (fun k v -> LabelPool.value k, v) map
| _ -> assert false
let rec sequence = function
......@@ -461,16 +451,11 @@ let map_xml map_pcdata map_other =
String_utf8 (i, j, u, cont)
| _ -> assert false
in
let rec aux = function
| Pair (Char c, tl) ->
let ustring = map_pcdata (U.mk_char (Chars.V.to_int c)) in
patch_string_utf8 (aux tl) (string_utf8 ustring)
| String_latin1 (i,j,s,tl) ->
let ustring = map_pcdata (U.mk_latin1 (String.sub s i j)) in
patch_string_utf8 (aux tl) (string_utf8 ustring)
| String_utf8 (i,j,s,tl) ->
let ustring = map_pcdata (U.mk (U.get_substr s i j)) in
patch_string_utf8 (aux tl) (string_utf8 ustring)
let rec aux v =
match v with
| Pair (Char _, _) | String_latin1 _ | String_utf8 _ ->
let (u, rest) = get_string_utf8 v in
patch_string_utf8 (aux rest) (string_utf8 (map_pcdata u))
| Pair (hd, tl) -> Pair (map_other hd, aux tl)
| Concat (_,_) as v -> eval_lazy_concat v; aux v
| v when compare v nil = 0 -> v
......
......@@ -26,8 +26,8 @@ type t =
module ValueSet: Set.S with type elt = t
exception CDuceExn of t
val raise': t -> 'a
val failwith': string -> 'a
val raise': t -> 'a (* "raise" for CDuce exceptions *)
val failwith': string -> 'a (* "failwith" for CDuce exceptions *)
val print: Format.formatter -> t -> unit
val dump_xml: Format.formatter -> t -> unit
......@@ -45,7 +45,7 @@ val vfalse : t
val vbool : bool -> t
(** @return a Record value from an associative list of fields *)
val vrecord : (string * t) list -> t
val vrecord : (Ns.qname * t) list -> t
val sequence : t list -> t
......@@ -67,7 +67,7 @@ val is_str : t -> bool
val get_int : t -> int
(** @return an associative list of fields from a Record value *)
val get_fields : t -> (string * t) list
val get_fields : t -> (Ns.qname * t) list
val compare : t -> t -> int
val ( |<| ): t -> t -> bool
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment