lutaml-model 0.8.192 → 0.8.193

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,263 @@
1
+ :doctype: book
2
+ = XML Schema Constraining Facets (Part 2: Datatypes)
3
+
4
+ .**length**:: Specifies an exact length. For strings, the number of characters; for binary types, bits or octets.
5
+ ====
6
+ [source,xml]
7
+ ----
8
+ <xs:restriction base="xs:string">
9
+ <xs:length value="5"/>
10
+ </xs:restriction>
11
+ ; Only values exactly 5 characters long—e.g., "Hello".
12
+ ----
13
+ ====
14
+
15
+ .**minLength**:: Defines a minimum length (inclusive).
16
+ ====
17
+ [source,xml]
18
+ ----
19
+ <xs:restriction base="xs:string">
20
+ <xs:minLength value="3"/>
21
+ </xs:restriction>
22
+ ; Values must have at least 3 characters—e.g., "Cat" or "Tree".
23
+ ----
24
+ ====
25
+
26
+ .**maxLength**:: Defines a maximum length (inclusive).
27
+ ====
28
+ [source,xml]
29
+ ----
30
+ <xs:restriction base="xs:string">
31
+ <xs:maxLength value="10"/>
32
+ </xs:restriction>
33
+ ; Values up to 10 characters allowed—e.g., "Short text".
34
+ ----
35
+ ====
36
+
37
+ .**pattern**:: Constrains values to match a given regular expression or ISO 8601 picture.
38
+ ====
39
+ [source,xml]
40
+ ----
41
+ <xs:restriction base="xs:string">
42
+ <xs:pattern value="[A-Za-z]{3}[0-9]{2}"/>
43
+ </xs:restriction>
44
+ ; Must match exactly three letters followed by two digits—e.g., "ABC12".
45
+ ----
46
+ ====
47
+
48
+ .**enumeration**:: Specifies a set of exact, permitted literal values.
49
+ ====
50
+ [source,xml]
51
+ ----
52
+ <xs:restriction base="xs:string">
53
+ <xs:enumeration value="Red"/>
54
+ <xs:enumeration value="Green"/>
55
+ <xs:enumeration value="Blue"/>
56
+ </xs:restriction>
57
+ ; Value must be one of: "Red", "Green", or "Blue".
58
+ ----
59
+ ====
60
+
61
+ .**whiteSpace**:: Defines normalization of whitespace: `preserve`, `replace`, or `collapse`.
62
+ ====
63
+ [source,xml]
64
+ ----
65
+ <xs:restriction base="xs:string">
66
+ <xs:whiteSpace value="collapse"/>
67
+ </xs:restriction>
68
+ ; Whitespace sequences collapse into single spaces.
69
+ ----
70
+ ====
71
+
72
+ .**maxInclusive**:: Value must be less than or equal to the specified limit.
73
+ ====
74
+ [source,xml]
75
+ ----
76
+ <xs:restriction base="xs:integer">
77
+ <xs:maxInclusive value="100"/>
78
+ </xs:restriction>
79
+ ; Accepts values up to 100, inclusive.
80
+ ----
81
+ ====
82
+
83
+ .**maxExclusive**:: Value must be strictly less than the specified limit.
84
+ ====
85
+ [source,xml]
86
+ ----
87
+ <xs:restriction base="xs:integer">
88
+ <xs:maxExclusive value="100"/>
89
+ </xs:restriction>
90
+ ; Accepts values less than 100 (e.g., 99), but not 100.
91
+ ----
92
+ ====
93
+
94
+ .**minInclusive**:: Value must be greater than or equal to the specified limit.
95
+ ====
96
+ [source,xml]
97
+ ----
98
+ <xs:restriction base="xs:integer">
99
+ <xs:minInclusive value="10"/>
100
+ </xs:restriction>
101
+ ; Accepts values from 10 upwards (10, 11, ...).
102
+ ----
103
+ ====
104
+
105
+ .**minExclusive**:: Value must be strictly greater than the specified limit.
106
+ ====
107
+ [source,xml]
108
+ ----
109
+ <xs:restriction base="xs:integer">
110
+ <xs:minExclusive value="10"/>
111
+ </xs:restriction>
112
+ ; Accepts values greater than 10 (e.g., 11), but not 10.
113
+ ----
114
+ ====
115
+
116
+ .**totalDigits**:: Specifies the maximum total number of digits in a number (integer + fractional).
117
+ ====
118
+ [source,xml]
119
+ ----
120
+ <xs:restriction base="xs:decimal">
121
+ <xs:totalDigits value="5"/>
122
+ </xs:restriction>
123
+ ; Accepts up to 5 digits total—e.g., "123.45", but not "1234.56" (6 digits).
124
+ ----
125
+ ====
126
+
127
+ .**fractionDigits**:: Limits maximum digits in the fractional portion.
128
+ ====
129
+ [source,xml]
130
+ ----
131
+ <xs:restriction base="xs:decimal">
132
+ <xs:fractionDigits value="2"/>
133
+ </xs:restriction>
134
+ ; Accepts values with up to two digits after the decimal—e.g., "12.34", but not "12.345".
135
+ ----
136
+ ====
137
+
138
+ == XML Schema Primitive Datatypes (Section 3.2)
139
+
140
+ Each primitive type includes:
141
+ - A **lexical format description**
142
+ - An **example value**
143
+ - The **constraining facets** that can be applied
144
+
145
+ [options="header"]
146
+ |===
147
+ | Datatype | Lexical Format / Pattern | Example Value | Applicable Constraining Facets
148
+
149
+ | **string** | Any Char sequence | "Hello, Schema" | length, minLength, maxLength, pattern, enumeration, whiteSpace
150
+
151
+ | **boolean** | "true"/"false"/"1"/"0" | true | pattern, enumeration, whiteSpace
152
+
153
+ | **decimal** | Numeric with optional fraction | 123.45 | totalDigits, fractionDigits, pattern, enumeration, whiteSpace, minInclusive, maxInclusive, minExclusive, maxExclusive
154
+
155
+ | **float** | Decimal or scientific notation | 1.23e4 | pattern, enumeration, whiteSpace, minInclusive, maxInclusive, minExclusive, maxExclusive
156
+
157
+ | **double** | Decimal or scientific notation | 1.23E4 | pattern, enumeration, whiteSpace, minInclusive, maxInclusive, minExclusive, maxExclusive
158
+
159
+ | **duration** | ISO 8601 Duration (PnYnMnDTnHnMnS) | P1Y2M3DT4H5M6S | pattern, enumeration, whiteSpace, minInclusive, maxInclusive, minExclusive, maxExclusive
160
+
161
+ | **dateTime** | ISO 8601 (CCYY‑MM‑DDThh:mm:ss) | 2025-09-09T12:34:56Z | pattern, enumeration, whiteSpace, minInclusive, maxInclusive, minExclusive, maxExclusive
162
+
163
+ | **time** | ISO 8601 (hh:mm:ss) | 12:34:56 | pattern, enumeration, whiteSpace, minInclusive, maxInclusive, minExclusive, maxExclusive
164
+
165
+ | **date** | ISO 8601 (CCYY‑MM‑DD) | 2025-09-09 | pattern, enumeration, whiteSpace, minInclusive, maxInclusive, minExclusive, maxExclusive
166
+
167
+ | **gYearMonth** | ISO 8601 (CCYY‑MM) | 2025-09 | pattern, enumeration, whiteSpace, minInclusive, maxInclusive, minExclusive, maxExclusive
168
+
169
+ | **gYear** | ISO 8601 (CCYY) | 2025 | pattern, enumeration, whiteSpace, minInclusive, maxInclusive, minExclusive, maxExclusive
170
+
171
+ | **gMonthDay** | ISO 8601 (--MM‑DD) | --09-09 | pattern, enumeration, whiteSpace, minInclusive, maxInclusive, minExclusive, maxExclusive
172
+
173
+ | **gDay** | ISO 8601 (---DD) | ---09 | pattern, enumeration, whiteSpace, minInclusive, maxInclusive, minExclusive, maxExclusive
174
+
175
+ | **gMonth** | ISO 8601 (--MM) | --09 | pattern, enumeration, whiteSpace, minInclusive, maxInclusive, minExclusive, maxExclusive
176
+
177
+ | **hexBinary** | Hex digits (0‑9, A‑F) | 0FAB | length, minLength, maxLength, pattern, enumeration, whiteSpace
178
+
179
+ | **base64Binary**| Base64-encoded data | "SGVsbG8=" | length, minLength, maxLength, pattern, enumeration, whiteSpace
180
+
181
+ | **anyURI** | URI reference | http://example.com | pattern, enumeration, whiteSpace, minInclusive, maxInclusive, minExclusive, maxExclusive
182
+
183
+ | **QName** | prefix:local or local | xs:string | pattern, enumeration, whiteSpace
184
+
185
+ | **NOTATION** | Declared Notation name | (user-declared) | pattern, enumeration, whiteSpace
186
+ |===
187
+
188
+ = Implementation Status in lutaml-model
189
+
190
+ This section documents the current implementation status of XML Schema constraining facets and primitive datatypes in the lutaml-model project.
191
+
192
+ == Constraining Facets Implementation Status
193
+
194
+ [options="header"]
195
+ |===
196
+ | Facet | Status | Implementation | Notes
197
+
198
+ | **length** | ❌ **NOT IMPLEMENTED** | - | Exact length validation not available
199
+ | **minLength** | ✅ **IMPLEMENTED** | `Lutaml::Model::Services::Type::Validator::String.validate_min_length!` | Full support for string minimum length
200
+ | **maxLength** | ✅ **IMPLEMENTED** | `Lutaml::Model::Services::Type::Validator::String.validate_max_length!` | Full support for string maximum length
201
+ | **pattern** | ✅ **IMPLEMENTED** | `Lutaml::Model::Services::Type::Validator::String.validate_pattern!` | Full regex pattern validation
202
+ | **enumeration** | ✅ **IMPLEMENTED** | `Lutaml::Model::Services::Type::Validator.validate_values!` | Full enumeration support
203
+ | **whiteSpace** | ⚠️ **PARTIALLY IMPLEMENTED** | `normalizedString` type with transform | Only basic normalization via transform
204
+ | **minInclusive** | ✅ **IMPLEMENTED** | `Lutaml::Model::Services::Type::Validator.validate_min_bound!` | Full support for inclusive minimum bounds
205
+ | **maxInclusive** | ✅ **IMPLEMENTED** | `Lutaml::Model::Services::Type::Validator.validate_max_bound!` | Full support for inclusive maximum bounds
206
+ | **minExclusive** | ✅ **IMPLEMENTED** | `Lutaml::Model::Services::Type::Validator.validate_min_bound!` | Full support for exclusive minimum bounds
207
+ | **maxExclusive** | ✅ **IMPLEMENTED** | `Lutaml::Model::Services::Type::Validator.validate_max_bound!` | Full support for exclusive maximum bounds
208
+ | **totalDigits** | ❌ **NOT IMPLEMENTED** | - | Total digit count validation not available
209
+ | **fractionDigits** | ❌ **NOT IMPLEMENTED** | - | Fractional digit count validation not available
210
+ |===
211
+
212
+ === Primitive Datatypes Implementation Status
213
+
214
+ [options="header"]
215
+ |===
216
+ | Datatype | Status | Implementation | Notes
217
+
218
+ | **string** | ✅ **IMPLEMENTED** | `Lutaml::Model::Type::String` | Full support with all applicable facets
219
+ | **boolean** | ✅ **IMPLEMENTED** | `Lutaml::Model::Type::Boolean` | Supports "true"/"false"/"1"/"0" formats
220
+ | **decimal** | ✅ **IMPLEMENTED** | `Lutaml::Model::Type::Decimal` | Requires BigDecimal, supports min/max bounds
221
+ | **float** | ✅ **IMPLEMENTED** | `Lutaml::Model::Type::Float` | Full support including scientific notation
222
+ | **double** | ✅ **IMPLEMENTED** | `Lutaml::Model::Type::Float` | Same implementation as float
223
+ | **integer** | ✅ **IMPLEMENTED** | `Lutaml::Model::Type::Integer` | Full support with bounds validation
224
+ | **dateTime** | ✅ **IMPLEMENTED** | `Lutaml::Model::Type::DateTime` | ISO 8601 format with timezone support
225
+ | **time** | ✅ **IMPLEMENTED** | `Lutaml::Model::Type::Time`, `Lutaml::Model::Type::TimeWithoutDate` | Full time support, specialized TimeWithoutDate
226
+ | **date** | ✅ **IMPLEMENTED** | `Lutaml::Model::Type::Date` | ISO 8601 date format
227
+ | **duration** | ❌ **NOT IMPLEMENTED** | - | ISO 8601 duration format not supported
228
+ | **gYearMonth** | ❌ **NOT IMPLEMENTED** | - | Gregorian year-month not supported
229
+ | **gYear** | ❌ **NOT IMPLEMENTED** | - | Gregorian year not supported
230
+ | **gMonthDay** | ❌ **NOT IMPLEMENTED** | - | Gregorian month-day not supported
231
+ | **gDay** | ❌ **NOT IMPLEMENTED** | - | Gregorian day not supported
232
+ | **gMonth** | ❌ **NOT IMPLEMENTED** | - | Gregorian month not supported
233
+ | **hexBinary** | ⚠️ **PARTIALLY IMPLEMENTED** | `Lutaml::Model::Type::String` with pattern | Via XML compiler with pattern validation
234
+ | **base64Binary** | ⚠️ **PARTIALLY IMPLEMENTED** | `Lutaml::Model::Type::String` with pattern | Via XML compiler with pattern validation
235
+ | **anyURI** | ⚠️ **PARTIALLY IMPLEMENTED** | `Lutaml::Model::Type::String` with pattern | Via XML compiler with URI pattern
236
+ | **QName** | ❌ **NOT IMPLEMENTED** | - | Qualified names not supported
237
+ | **NOTATION** | ❌ **NOT IMPLEMENTED** | - | Notation declarations not supported
238
+ |===
239
+
240
+ === Missing Features and Limitations
241
+
242
+ ==== Not Implemented Constraining Facets
243
+ - `length` (exact length validation)
244
+ - `totalDigits` (total digit count for decimals)
245
+ - `fractionDigits` (fractional digit count for decimals)
246
+ - Complete `whiteSpace` facet (only basic normalization via `normalizedString`)
247
+
248
+ ==== Not Implemented Primitive Types
249
+ - `duration` (ISO 8601 duration format)
250
+ - `gYearMonth`, `gYear`, `gMonthDay`, `gDay`, `gMonth` (Gregorian calendar fragments)
251
+ - `QName` (qualified names)
252
+ - `NOTATION` (notation declarations)
253
+
254
+ ==== Partially Implemented Types
255
+ - `hexBinary` and `base64Binary` are implemented as string types with pattern validation
256
+ - `anyURI` is implemented as string type with URI pattern validation
257
+
258
+ ==== Implementation Notes
259
+ - The project uses Ruby's native types where possible (`Time`, `Date`, `DateTime`, `BigDecimal`)
260
+ - Validation is performed through the `Lutaml::Model::Services::Type::Validator` hierarchy
261
+ - XML Schema compilation generates appropriate type mappings with validation constraints
262
+ - Custom types can extend base types for specialized behavior (see documentation examples)
263
+ - Error handling is provided through specific error classes like `MinLengthError`, `MaxLengthError`, `PatternNotMatchedError`, etc.
@@ -0,0 +1,129 @@
1
+ = XML Namespaces Specification Reference
2
+
3
+ Based on: W3C Recommendation "Namespaces in XML 1.0" (Third Edition, 8 December 2009)
4
+ ([w3.org](https://www.w3.org/TR/xml-names/))
5
+
6
+ == 1. Core Definitions & Concepts
7
+
8
+ Namespaces provide a method to qualify element and attribute names via a unique namespace URI, yielding *expanded names*—pairs of {namespace name, local name} to avoid naming collisions.
9
+ ([w3.org](https://www.w3.org/TR/xml-names/))
10
+
11
+ **Qualified Name (QName):**
12
+ A *prefixed name* (`prefix:localPart`) or *unprefixed name* (`localPart`) used in elements and attributes. The prefix acts only as a placeholder for the namespace URI.
13
+ ([w3.org](https://www.w3.org/TR/xml-names/))
14
+
15
+ == 2. Namespace Declarations
16
+
17
+ Namespace bindings occur via attributes:
18
+ - `xmlns:prefix="namespaceURI"` — *Prefixed Namespace Declaration*
19
+ - `xmlns="namespaceURI"` — *Default Namespace Declaration*
20
+ ([w3.org](https://www.w3.org/TR/xml-names/))
21
+
22
+ **Rules:**
23
+ - The attribute value must be a URI reference or the empty string.
24
+ - The empty string value on a default namespace declaration clears the default namespace in the scope.
25
+ ([w3.org](https://www.w3.org/TR/xml-names/))
26
+
27
+ **Best Practices:**
28
+ - Namespace names should be unique and persistent but need not resolve to actual schema documents.
29
+ ([w3.org](https://www.w3.org/TR/xml-names/))
30
+
31
+ == 3. Reserved Prefixes & Restrictions
32
+
33
+ - `xml` prefix is bound to `http://www.w3.org/XML/1998/namespace` and:
34
+ - **Must not** be used for other namespaces.
35
+ - Declaration is optional but allowed.
36
+ ([w3.org](https://www.w3.org/TR/xml-names/))
37
+
38
+ - `xmlns` prefix is reserved solely for namespace declarations (`xmlns:...`) and is bound to `http://www.w3.org/2000/xmlns/`; cannot be used as a namespace or element prefix.
39
+ ([w3.org](https://www.w3.org/TR/xml-names/))
40
+
41
+ - Any other prefix starting with the letters `x`, `m`, `l` (in any case mix) is **reserved**:
42
+ - **Should not** be used for other purposes.
43
+ - Processors **must not** treat its use as a fatal error.
44
+ ([w3.org](https://www.w3.org/TR/xml-names/))
45
+
46
+ == 4. Namespace Scope & Defaulting
47
+
48
+ Namespace declarations are scoped to the element in which they appear and its descendants, unless overridden by inner declarations.
49
+ Default namespaces apply only to unprefixed **element names**, not attributes. Attributes without a prefix are in no namespace.
50
+ ([w3.org](https://www.w3.org/TR/xml-names/))
51
+
52
+ == 5. Namespace Name Matching
53
+
54
+ Namespace URIs are compared as literal strings—case-sensitive and without URI normalization or resolving.
55
+ Even semantically equivalent URIs with different encoding or case are considered distinct.
56
+ ([w3.org](https://www.w3.org/TR/xml-names/))
57
+
58
+ == 6. Validation Constraints
59
+
60
+ XML namespace-well-formedness enforces:
61
+
62
+ - Element and attribute names must:
63
+ - Match the QName production.
64
+ - Contain **0 or 1 colon**.
65
+ - Be bound to declared prefixes (unless `xml`/`xmlns`).
66
+ ([turn0search0](#), [turn0view0](#))
67
+
68
+ - Namespace declaration prefixes must have non-empty values—can't "undeclare" a prefix.
69
+ ([turn0search0](#), [turn0view0](#))
70
+
71
+ - No duplicate attributes with the same expanded name (same namespace URI + local name).
72
+ ([turn0search0](#))
73
+
74
+ - Tokens beyond element/attribute names that require `Name` syntax must match `NCName`.
75
+ This includes entity names, PI targets, DTD names.
76
+ ([turn0search0](#), [turn0search1](#))
77
+
78
+ == 7. Processor Conformance
79
+
80
+ A conforming processor must:
81
+ - Detect and report violations of namespace-well-formedness (e.g., invalid prefix usage), though checking URI legitimacy is *not required*.
82
+ - A *namespace-validating* processor also ensures tokens follow `NCName` where appropriate.
83
+ ([turn0search1](#))
84
+
85
+ == 8. Summary Table
86
+
87
+ [options="header"]
88
+ |===
89
+ | Feature | Constraint / Behavior
90
+
91
+ | Namespace Declaration | `xmlns:prefix` or `xmlns` with valid URI or empty (for default namespace)
92
+
93
+ | Reserved Prefixes | `xml`, `xmlns`, and `xml...`, `XML...` etc.—constraints enforced
94
+
95
+ | QName Syntax | Element/attribute names must be valid QName (0 or 1 colon)
96
+
97
+ | Prefix Binding | Prefix must be declared or one of reserved ones (`xml`, `xmlns`)
98
+
99
+ | Namespace URI Comparison | Strict string-level match, no normalization
100
+
101
+ | Default Namespace | Applies to elements only, not attributes
102
+
103
+ | Attribute Uniqueness | No duplicate expanded names allowed on an element
104
+
105
+ | Non-QName Tokens | Must match `NCName` if required by XML spec (e.g., ENTITY names)
106
+
107
+ | Processor Responsibilities | Report well-formedness violations; validation optional based on conformance level
108
+ |===
109
+
110
+ == XML Namespace Implementation Status
111
+
112
+ This table summarizes the implementation status of XML namespace features and constraints in the codebase, based on the specification in `xml_namespace.adoc`.
113
+
114
+ [options="header"]
115
+ |===
116
+ | Feature/Constraint | Status | Notes
117
+ | Namespace declaration (xmlns, xmlns:prefix) | Implemented | Supported in mapping, parsing, serialization
118
+ | Reserved prefixes (`xml`, `xmlns`, `xml...`) | Partially Implemented | `xml` prefix handled, but not all reserved prefix rules enforced
119
+ | QName syntax (0 or 1 colon) | Not Implemented | No explicit validation of QName structure
120
+ | Prefix binding (declared or reserved) | Partially Implemented | Declared prefixes supported, reserved prefix enforcement incomplete
121
+ | Namespace URI comparison (literal, case-sensitive) | Implemented | URIs used as literal strings
122
+ | Default namespace (elements only) | Implemented | Default namespace supported for elements, not attributes
123
+ | Attribute uniqueness (no duplicate expanded names) | Not Implemented | No explicit check for duplicate expanded names
124
+ | NCName validation (non-QName tokens) | Not Implemented | No explicit NCName validation for tokens
125
+ | Namespace scope & overriding | Partially Implemented | Basic scoping via mapping, advanced override rules not enforced
126
+ | Undeclaring prefixes (empty value) | Not Implemented | No explicit handling of undeclaration
127
+ | Processor conformance (error reporting) | Partially Implemented | Well-formedness errors reported, but not all namespace errors
128
+ | Namespace-well-formedness validation | Partially Implemented | Some checks via mapping/tests, not full spec coverage
129
+ |===