/[svn]/schema/schema_xml.ml
ViewVC logotype

Diff of /schema/schema_xml.ml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 806 by abate, Tue Jul 10 18:04:23 2007 UTC revision 812 by abate, Tue Jul 10 18:04:55 2007 UTC
# Line 4  Line 4 
4  open Pxp_tree_parser  open Pxp_tree_parser
5  open Pxp_types  open Pxp_types
6    
7    open Encodings
8    open Encodings.Utf8.Pcre
9    
10  type pxp_node =  type pxp_node =
11    ('a Pxp_document.node Pxp_document.extension as 'a) Pxp_document.node    ('a Pxp_document.node Pxp_document.extension as 'a) Pxp_document.node
12  type pxp_document =  type pxp_document =
13    ('a Pxp_document.node Pxp_document.extension as 'a) Pxp_document.document    ('a Pxp_document.node Pxp_document.extension as 'a) Pxp_document.document
14    
15  let regexp' s = Pcre.regexp ~flags:[`UTF8] s  let xsd_RE = pcre_regexp "^xsd:"
16  let xsd_RE = regexp' "^xsd:"  
17  let namespace_split name =  (* Pxp_aux.namespace_split *)  let has_xsd_prefix s = Pcre.pmatch ~rex:xsd_RE (Utf8.get_str s)
18    try  
19      let n = String.index name ':' in   (* may raise Not_found *)  let xsd_namespace = Utf8.mk "http://www.w3.org/2001/XMLSchema"
20      let prefix = String.sub name 0 n in  let xsi_namespace = Utf8.mk "http://www.w3.org/2001/XMLSchema-instance"
21      let localname = String.sub name (n+1) (String.length name - n - 1)  let xsd_prefix = Utf8.mk "xsd"
22      in  let xsi_prefix = Utf8.mk "xsi"
23      (prefix, localname)  let add_xsd_prefix =
24    with    let prefix = Utf8.concat xsd_prefix (Utf8.mk ":") in
25        Not_found -> ("", name)    fun s -> Utf8.concat prefix s
   
 let has_xsd_prefix s = Pcre.pmatch ~rex:xsd_RE s  
   
 let xsd_namespace = "http://www.w3.org/2001/XMLSchema"  
 let xsi_namespace = "http://www.w3.org/2001/XMLSchema-instance"  
 let xsd_prefix = "xsd"  
 let xsi_prefix = "xsi"  
26    
27  let schema_ns_prefixes =  let schema_ns_prefixes =
28    [ xsd_prefix, xsd_namespace; xsi_prefix, xsi_namespace ]    [ xsd_prefix, xsd_namespace; xsi_prefix, xsi_namespace ]
# Line 34  Line 30 
30  let spec = default_namespace_spec  let spec = default_namespace_spec
31  let new_xsd_config () =  let new_xsd_config () =
32    let ns_manager = new Pxp_dtd.namespace_manager in    let ns_manager = new Pxp_dtd.namespace_manager in
33    List.iter (fun (p, ns) -> ns_manager#add_namespace p ns) schema_ns_prefixes;    List.iter
34        (fun (p, ns) -> ns_manager#add_namespace (Utf8.get_str p) (Utf8.get_str ns))
35        schema_ns_prefixes;
36    { default_namespace_config with    { default_namespace_config with
37        Pxp_types.enable_namespace_processing = Some ns_manager        Pxp_types.enable_namespace_processing = Some ns_manager
38    }    }
# Line 158  Line 156 
156    
157      exception PxpHelpers of exn      exception PxpHelpers of exn
158      let _raise e = raise (PxpHelpers e)      let _raise e = raise (PxpHelpers e)
159      let space_RE = regexp' " "      let space_RE = pcre_regexp " "
160    
161      let _tag_name (n: pxp_node) =      let _tag_name (n: pxp_node) =
162        match n#node_type with        match n#node_type with
163        | T_element tag -> tag        | T_element tag -> Utf8.mk tag
164        | _ -> raise Not_found        | _ -> raise Not_found
165    
166      let _has_attribute name (n: pxp_node) =      let _has_attribute name (n: pxp_node) =
# Line 174  Line 172 
172    
173      let _attribute name (n: pxp_node) =      let _attribute name (n: pxp_node) =
174        match n#attribute name with        match n#attribute name with
175        | Value v -> v        | Value v -> Utf8.mk v
176        | _ -> raise Not_found        | _ -> raise Not_found
177    
178      let _has_element e (n: pxp_node) =      let _has_element e (n: pxp_node) =
# Line 208  Line 206 
206    
207    (** export Ns.t version of defined namespaces *)    (** export Ns.t version of defined namespaces *)
208    
209  let xsd_namespace = Ns.mk_ascii xsd_namespace  let xsd_namespace = Ns.mk xsd_namespace
210  let xsi_namespace = Ns.mk_ascii xsi_namespace  let xsi_namespace = Ns.mk xsi_namespace
211    

Legend:
Removed from v.806  
changed lines
  Added in v.812

CVS Admin">CVS Admin
ViewVC Help
Powered by ViewVC 1.1.5