Commit 7737cffa authored by Pietro Abate's avatar Pietro Abate
Browse files

[r2003-11-21 12:50:37 by szach] added targetNamespace to schema representations

Original author: szach
Date: 2003-11-21 12:50:38+00:00
parent 87240950
open Printf
open Schema_types
open Schema_common
......@@ -44,6 +45,8 @@ exception Schema_builtin_error of string
let simple_type_error name =
raise (Schema_builtin_error (Schema_xml.xsd_prefix ^ name))
let qualify s = (Schema_xml.xsd_namespace, Encodings.Utf8.mk s)
(* regular expressions used to validate built-in types *)
let timezone_RE_raw = "(Z)|(([+-])?(\\d{2}):(\\d{2}))"
......@@ -58,13 +61,13 @@ let gMonth_RE_raw = "--(\\d{2})--(%s)?"
(** {2 CDuce types} *)
let positive_field = false, "positive", Builtin_defs.bool
let year_field = false, "year", Builtin_defs.int
let month_field = false, "month", Builtin_defs.int
let day_field = false, "day", Builtin_defs.int
let hour_field = false, "hour", Builtin_defs.int
let minute_field = false, "minute", Builtin_defs.int
let second_field = false, "second", Builtin_defs.int
let positive_field = false, qualify "positive", Builtin_defs.bool
let year_field = false, qualify "year", Builtin_defs.int
let month_field = false, qualify "month", Builtin_defs.int
let day_field = false, qualify "day", Builtin_defs.int
let hour_field = false, qualify "hour", Builtin_defs.int
let minute_field = false, qualify "minute", Builtin_defs.int
let second_field = false, qualify "second", Builtin_defs.int
(* TODO this should be a decimal *)
let time_type_fields = [ hour_field; minute_field; second_field ]
let date_type_fields = [ year_field; month_field; day_field ]
......@@ -73,18 +76,18 @@ let date_type_fields = [ year_field; month_field; day_field ]
expressible with CDuce types *)
let duration_type = Types.rec_of_list' [
positive_field;
true, "year", Builtin_defs.int;
true, "month", Builtin_defs.int;
true, "day", Builtin_defs.int;
true, "hour", Builtin_defs.int;
true, "minute", Builtin_defs.int;
true, "second", Builtin_defs.int; (* TODO this should be a decimal *)
true, qualify "year", Builtin_defs.int;
true, qualify "month", Builtin_defs.int;
true, qualify "day", Builtin_defs.int;
true, qualify "hour", Builtin_defs.int;
true, qualify "minute", Builtin_defs.int;
true, qualify "second", Builtin_defs.int; (* TODO this should be a decimal *)
]
let timezone_type = Types.rec_of_list' [
false, "positive", Builtin_defs.bool;
positive_field;
hour_field; minute_field
]
let timezone_type_fields = [ true, "timezone", timezone_type ]
let timezone_type_fields = [ true, qualify "timezone", timezone_type ]
let time_type = Types.rec_of_list' (time_type_fields @ timezone_type_fields)
let date_type = Types.rec_of_list' (positive_field :: date_type_fields)
let dateTime_type =
......@@ -160,8 +163,7 @@ let parse_timezone' = function
| "" -> []
| v -> [ "timezone", Value.vrecord (parse_timezone v) ]
let validate_string s =
Value.string_utf8 (Encodings.Utf8.mk s)
let validate_string s = Value.string_utf8 (Encodings.Utf8.mk s)
let validate_normalizedString s =
validate_string (normalize_white_space `Replace s)
let validate_token s =
......
......@@ -545,6 +545,11 @@ class lazy_resolver =
(** schemas namespaces handling *)
method targetNamespace =
match targetNamespace with
| None -> Ns.empty
| Some s -> Ns.mk_latin1 s
(* qualify names of entities before registering them with defined
* targetNamespace, if any *)
method private qualify_name s =
......@@ -774,6 +779,7 @@ let schema_of_node root =
resolver#register_model_group name (parse_model_group_def resolver' n)
| _ -> ());
{
targetNamespace = resolver#targetNamespace;
types = resolver#type_defs;
attributes = resolver#att_decls;
elements = resolver#elt_decls;
......
......@@ -110,6 +110,7 @@ type attribute_group_definition =
attribute_use list
type schema = {
targetNamespace: Ns.t;
types: type_definition list;
attributes: attribute_declaration list;
elements: element_declaration list;
......
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