| 1 |
|
| 2 |
(** Types used by all the Schema modules.
|
| 3 |
This module comes in .mli part only, hence no value and/or exceptions are
|
| 4 |
available here. See Schema_common.
|
| 5 |
*)
|
| 6 |
|
| 7 |
(**
|
| 8 |
Glossary:
|
| 9 |
XSD XML Schema Document
|
| 10 |
PSV Post Schema Validation
|
| 11 |
PSVI Post Schema Validation Infoset
|
| 12 |
*)
|
| 13 |
|
| 14 |
open Encodings
|
| 15 |
|
| 16 |
(** {2 XSD representation} *)
|
| 17 |
|
| 18 |
type xs_nonNegativeInteger = Intervals.V.t (* = Big_int.big_int *)
|
| 19 |
(* type xs_positiveInteger = Intervals.V.t *)
|
| 20 |
|
| 21 |
type derivation_type = [ `Extension | `Restriction ]
|
| 22 |
type value_constraint = [ `Fixed of Value.t | `Default of Value.t ]
|
| 23 |
type white_space_handling = [ `Preserve | `Replace | `Collapse ]
|
| 24 |
|
| 25 |
type facets = {
|
| 26 |
length: (xs_nonNegativeInteger * bool) option; (* length, fixed *)
|
| 27 |
minLength: (xs_nonNegativeInteger * bool) option; (* length, fixed *)
|
| 28 |
maxLength: (xs_nonNegativeInteger * bool) option; (* length, fixed *)
|
| 29 |
(* pattern: Schema_regexp.regexp list; (* list of ANDed patterns *) *)
|
| 30 |
enumeration: Value.ValueSet.t option;
|
| 31 |
whiteSpace: white_space_handling * bool; (* handling, fixed *)
|
| 32 |
maxInclusive: (Value.t * bool) option; (* max, fixed *)
|
| 33 |
maxExclusive: (Value.t * bool) option; (* max, fixed *)
|
| 34 |
minInclusive: (Value.t * bool) option; (* min, fixed *)
|
| 35 |
minExclusive: (Value.t * bool) option; (* min, fixed *)
|
| 36 |
(*
|
| 37 |
totalDigits: (xs_positiveInteger * bool) option; (* digits, fixed *)
|
| 38 |
fractionDigits: (xs_nonNegativeInteger * bool) option; (* digits, fixed *)
|
| 39 |
*)
|
| 40 |
}
|
| 41 |
|
| 42 |
type simple_type_definition =
|
| 43 |
| Primitive of Utf8.t
|
| 44 |
| Derived of
|
| 45 |
Utf8.t option * (* name *)
|
| 46 |
variety *
|
| 47 |
facets *
|
| 48 |
simple_type_definition (* base *)
|
| 49 |
|
| 50 |
and variety =
|
| 51 |
| Atomic of simple_type_definition (* a Primitive _ *)
|
| 52 |
| List of simple_type_definition (* Variety (simple_type_definition) =
|
| 53 |
Atomic || Union (of atomic) *)
|
| 54 |
| Union of simple_type_definition list
|
| 55 |
|
| 56 |
type attribute_declaration =
|
| 57 |
Utf8.t * (* name *)
|
| 58 |
simple_type_definition * (* type *)
|
| 59 |
value_constraint option
|
| 60 |
|
| 61 |
type attribute_use =
|
| 62 |
bool * (* required *)
|
| 63 |
attribute_declaration *
|
| 64 |
value_constraint option
|
| 65 |
|
| 66 |
(* first construction as per predictive parsing. None stands for epsilon, Some
|
| 67 |
* Utf8.t stands for a start tag of identical name *)
|
| 68 |
type first = Utf8.t option list
|
| 69 |
|
| 70 |
type term =
|
| 71 |
| Elt of element_declaration ref
|
| 72 |
| Model of model_group
|
| 73 |
|
| 74 |
and model_group =
|
| 75 |
| All of particle list
|
| 76 |
| Choice of particle list
|
| 77 |
| Sequence of particle list
|
| 78 |
|
| 79 |
and content_type =
|
| 80 |
| CT_empty
|
| 81 |
| CT_simple of simple_type_definition
|
| 82 |
| CT_model of
|
| 83 |
particle *
|
| 84 |
bool (* mixed *)
|
| 85 |
|
| 86 |
and particle =
|
| 87 |
xs_nonNegativeInteger * (* minOccurs *)
|
| 88 |
xs_nonNegativeInteger option * (* maxOccurs (None = "unbounded") *)
|
| 89 |
term *
|
| 90 |
first
|
| 91 |
|
| 92 |
and element_declaration =
|
| 93 |
int * (* unique id *)
|
| 94 |
Utf8.t * (* name *)
|
| 95 |
type_definition ref * (* type *)
|
| 96 |
value_constraint option
|
| 97 |
|
| 98 |
and complex_type_definition =
|
| 99 |
int * (* unique id *)
|
| 100 |
Utf8.t option * (* name *)
|
| 101 |
type_definition * (* base *)
|
| 102 |
derivation_type *
|
| 103 |
attribute_use list *
|
| 104 |
content_type
|
| 105 |
|
| 106 |
and type_definition =
|
| 107 |
| AnyType
|
| 108 |
| Simple of simple_type_definition
|
| 109 |
| Complex of complex_type_definition
|
| 110 |
|
| 111 |
type model_group_definition =
|
| 112 |
Utf8.t * (* name *)
|
| 113 |
model_group
|
| 114 |
|
| 115 |
type attribute_group_definition =
|
| 116 |
Utf8.t * (* name *)
|
| 117 |
attribute_use list
|
| 118 |
|
| 119 |
type schema = {
|
| 120 |
targetNamespace: Ns.t;
|
| 121 |
types: type_definition list;
|
| 122 |
attributes: attribute_declaration list;
|
| 123 |
elements: element_declaration list;
|
| 124 |
attribute_groups: attribute_group_definition list;
|
| 125 |
model_groups: model_group_definition list;
|
| 126 |
}
|
| 127 |
|
| 128 |
(** {2 Events} see Schema_events module *)
|
| 129 |
|
| 130 |
type event =
|
| 131 |
| E_start_tag of Ns.qname
|
| 132 |
| E_end_tag of Ns.qname
|
| 133 |
| E_attribute of Ns.qname * Encodings.Utf8.t (* qualified name, value *)
|
| 134 |
| E_char_data of Encodings.Utf8.t
|
| 135 |
|
| 136 |
(** {2 Misc} *)
|
| 137 |
|
| 138 |
(* kind of a schema component *)
|
| 139 |
type component_kind =
|
| 140 |
[ `Type | `Element | `Attribute | `Attribute_group | `Model_group ] option
|
| 141 |
|
| 142 |
type component =
|
| 143 |
| Type of type_definition
|
| 144 |
| Element of element_declaration
|
| 145 |
| Attribute of attribute_declaration
|
| 146 |
| Attribute_group of attribute_group_definition
|
| 147 |
| Model_group of model_group_definition
|
| 148 |
|