Commit f03d53ca authored by Pietro Abate's avatar Pietro Abate
Browse files

[r2003-11-26 16:20:56 by szach] compute FIRST while parsing schemas

Original author: szach
Date: 2003-11-26 16:20:56+00:00
parent 9515d215
...@@ -22,6 +22,7 @@ let debug_print ?(n: pxp_node option) s = ...@@ -22,6 +22,7 @@ let debug_print ?(n: pxp_node option) s =
let space_RE = pcre_regexp " " let space_RE = pcre_regexp " "
let split s = pcre_split ~rex:space_RE s let split s = pcre_split ~rex:space_RE s
let unqualify s = snd (Ns.split_qname s)
let hashtbl_deref tbl = let hashtbl_deref tbl =
(* ASSUMPTION: no multiple bindings *) (* ASSUMPTION: no multiple bindings *)
let tbl' = Hashtbl.create 1024 in let tbl' = Hashtbl.create 1024 in
...@@ -384,7 +385,8 @@ let rec parse_complex_type (resolver: resolver) n = ...@@ -384,7 +385,8 @@ let rec parse_complex_type (resolver: resolver) n =
let particle = parse_particle resolver p_node in let particle = parse_particle resolver p_node in
CT_model (particle, mixed)) CT_model (particle, mixed))
| `Extension -> | `Extension ->
let base_ct = content_type_of_type !base in let base_ct = content_type_of_type !base in (* TODO BUG HERE if base =
AnyType *)
(match particle_node with (match particle_node with
| None -> base_ct | None -> base_ct
| Some pnode -> | Some pnode ->
...@@ -392,10 +394,11 @@ let rec parse_complex_type (resolver: resolver) n = ...@@ -392,10 +394,11 @@ let rec parse_complex_type (resolver: resolver) n =
(match base_ct with (match base_ct with
| CT_empty -> CT_model (particle, mixed) | CT_empty -> CT_model (particle, mixed)
| CT_model (p, _) -> | CT_model (p, _) ->
let model = Sequence (p::[particle]) in
CT_model CT_model
((Intervals.V.one, ((Intervals.V.one, Some (Intervals.V.one), Model model,
Some (Intervals.V.one), first_of_model_group model),
Model (Sequence (p::[particle]))), mixed) mixed)
| CT_simple _ -> assert false)) | CT_simple _ -> assert false))
in in
complex name !base derivation_type uses content_type complex name !base derivation_type uses content_type
...@@ -441,21 +444,23 @@ and parse_particle (resolver: resolver) n = ...@@ -441,21 +444,23 @@ and parse_particle (resolver: resolver) n =
let min, max = parse_min_max n in let min, max = parse_min_max n in
match n#node_type with match n#node_type with
| T_element "xsd:element" -> | T_element "xsd:element" ->
let elt_decl = let elt_decl, first =
if _has_attribute "ref" n then if _has_attribute "ref" n then
resolver#resolve_elt ~now:false (_attribute "ref" n) let ref = _attribute "ref" n in
(resolver#resolve_elt ~now:false ref, [ Some ref ])
else (* no "ref" attribute *) else (* no "ref" attribute *)
ref (parse_elt_decl resolver n) let decl = parse_elt_decl resolver n in
(ref decl, [ Some (name_of_element_declaration decl) ])
in in
min, max, Elt elt_decl (min, max, Elt elt_decl, first)
| T_element "xsd:group" -> | T_element "xsd:group" ->
let model_group = let model_group =
snd (resolver#resolve_model_group (_attribute "ref" n)) snd (resolver#resolve_model_group (_attribute "ref" n))
in in
min, max, Model model_group (min, max, Model model_group, first_of_model_group model_group)
| T_element "xsd:all" | T_element "xsd:sequence" | T_element "xsd:choice" -> | T_element "xsd:all" | T_element "xsd:sequence" | T_element "xsd:choice" ->
let model_group = parse_model_group resolver n in let model_group = parse_model_group resolver n in
min, max, Model model_group (min, max, Model model_group, first_of_model_group model_group)
| _ -> assert false | _ -> assert false
and parse_model_group (resolver: resolver) n = and parse_model_group (resolver: resolver) n =
......
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