lutaml-model 0.8.192 → 0.8.194

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,718 @@
1
+ = XML Base (`xml:base`) Specification Reference
2
+
3
+ This document presents a detailed specification of the `xml:base` attribute as defined in the W3C XML Base Recommendation (Second Edition, 2009). This specification provides a facility similar to HTML BASE for defining base URIs for parts of XML documents.
4
+
5
+ Source: **W3C XML Base (Second Edition)** +
6
+ W3C Recommendation 28 January 2009
7
+
8
+ == Abstract
9
+
10
+ XML Base describes a facility, similar to that of HTML BASE, for defining base URIs for parts of XML documents. This specification provides a mechanism for providing base URI services to XLink and other XML applications that benefit from additional control over relative URIs.
11
+
12
+
13
+ == 1. Introduction and Purpose
14
+
15
+ The `xml:base` attribute allows authors to explicitly redefine the base URI for parts of an XML document, enabling consistent resolution of relative URIs—especially in linking contexts like XLink, style sheets, or external resources.
16
+
17
+ === Background
18
+
19
+ The XML Linking Language (XLink) defines XML constructs to describe links between resources. One of the requirements on XLink is to support HTML linking constructs in a generic way. The HTML BASE element allows authors to explicitly specify a document's base URI for resolving relative URIs in links to external images, applets, form-processing programs, style sheets, and other resources.
20
+
21
+ XML Base provides a mechanism for providing base URI services to XLink and other XML applications as a modular specification. The syntax consists of a single XML attribute named `xml:base`.
22
+
23
+ === Deployment
24
+
25
+ The deployment of XML Base is through normative reference by new specifications (e.g., XLink and the XML Infoset). Applications and specifications built upon these technologies will natively support XML Base. The behavior of `xml:base` attributes in applications based on specifications that do not have direct or indirect normative reference to XML Base is undefined.
26
+
27
+ === Scope
28
+
29
+ This specification does not attempt to specify which text strings in a document are to be interpreted as URIs. That is the responsibility of each XML vocabulary. The question addressed by this specification is: given a relative URI in an XML document, what base URI is it resolved against?
30
+
31
+
32
+ == 2. Terminology
33
+
34
+ [IMPORTANT]
35
+ ====
36
+ The key words MUST, MUST NOT, REQUIRED, SHALL, SHALL NOT, SHOULD, SHOULD NOT, RECOMMENDED, MAY, and OPTIONAL in this specification are to be interpreted as described in RFC 2119.
37
+ ====
38
+
39
+ The terms base URI and relative URI are used in this specification as they are defined in RFC 3986.
40
+
41
+ **Base URI**: The URI used to resolve any relative URI references found within a document.
42
+
43
+ **Relative URI**: A URI reference that does not begin with a scheme name and is resolved relative to a base URI.
44
+
45
+ **Legacy Extended IRI (LEIRI)**: An extension of URI syntax that allows characters beyond those permitted in URIs, as defined in the W3C Note "Legacy extended IRIs for XML resource identification".
46
+
47
+ == 3. The xml:base Attribute Specification
48
+
49
+ - **Name**: `xml:base`
50
+ - **Namespace**: `http://www.w3.org/XML/1998/namespace` (bound to the reserved `xml:` prefix)
51
+ - **Value Type**: Legacy Extended IRI (LEIRI), which accepts characters beyond standard URIs
52
+
53
+ In namespace-aware XML processors, the "xml" prefix is bound to the namespace name `http://www.w3.org/XML/1998/namespace` as described in Namespaces in XML. Note that `xml:base` can still be used by non-namespace-aware processors.
54
+
55
+ === Basic Example
56
+
57
+ .XLink Document with xml:base
58
+ [source,xml]
59
+ ----
60
+ <?xml version="1.0"?>
61
+ <doc xml:base="http://example.org/today/"
62
+ xmlns:xlink="http://www.w3.org/1999/xlink">
63
+ <head>
64
+ <title>Virtual Library</title>
65
+ </head>
66
+ <body>
67
+ <paragraph>See <link xlink:type="simple"
68
+ xlink:href="new.xml">what's new</link>!</paragraph>
69
+ <paragraph>Check out the hot picks of the day!</paragraph>
70
+ <olist xml:base="/hotpicks/">
71
+ <item>
72
+ <link xlink:type="simple" xlink:href="pick1.xml">Hot Pick #1</link>
73
+ </item>
74
+ <item>
75
+ <link xlink:type="simple" xlink:href="pick2.xml">Hot Pick #2</link>
76
+ </item>
77
+ <item>
78
+ <link xlink:type="simple" xlink:href="pick3.xml">Hot Pick #3</link>
79
+ </item>
80
+ </olist>
81
+ </body>
82
+ </doc>
83
+ ----
84
+
85
+ The URIs in this example resolve to full URIs as follows:
86
+
87
+ - "what's new" resolves to the URI `http://example.org/today/new.xml`
88
+ - "Hot Pick #1" resolves to the URI `http://example.org/hotpicks/pick1.xml`
89
+ - "Hot Pick #2" resolves to the URI `http://example.org/hotpicks/pick2.xml`
90
+ - "Hot Pick #3" resolves to the URI `http://example.org/hotpicks/pick3.xml`
91
+
92
+ === Validity Considerations
93
+
94
+ [NOTE]
95
+ ====
96
+ This specification does not give the `xml:base` attribute any special status as far as XML validity is concerned. In a valid document the attribute MUST be declared in the DTD, and similar considerations apply to other schema languages.
97
+ ====
98
+
99
+ .DTD Declaration Example
100
+ [source,xml]
101
+ ----
102
+ <!ATTLIST doc xml:base CDATA #IMPLIED>
103
+ <!ATTLIST olist xml:base CDATA #IMPLIED>
104
+ ----
105
+
106
+ == 5. Resolving Relative URIs
107
+
108
+ === Relation to RFC 3986
109
+
110
+ RFC 3986 provides for base URI information to be embedded within a document. The rules for determining the base URI can be summarized as follows (highest priority to lowest):
111
+
112
+ 1. The base URI is embedded in the document's content
113
+ 2. The base URI is that of the encapsulating entity (message, document, or none)
114
+ 3. The base URI is the URI used to retrieve the entity
115
+ 4. The base URI is defined by the context of the application
116
+
117
+ This specification defines the details of rule #1 for embedding base URI information in the specific case of XML documents.
118
+
119
+ === Granularity of Base URI Information
120
+
121
+ Relative URIs appearing in an XML document are always resolved relative to either an element, a document entity, or an external entity. There is NO provision for finer granularity, such as per-attribute, per-character, or per-entity base information.
122
+
123
+ **Important Limitations:**
124
+ - Internal entities (whether declared in the internal subset or in an external DTD) are NOT considered to set a base URI separate from the base URI in scope for the entity reference
125
+ - Freestanding text (text not enclosed in an element) in an external entity does NOT set a separate base URI
126
+
127
+ === Base URI Computation Rules
128
+
129
+ Base URI resolution follows a clear hierarchy (highest to lowest priority):
130
+
131
+ 1. **Element with xml:base**: The base URI specified by an `xml:base` attribute on the element, if one exists
132
+ 2. **Parent Element**: The base URI of the element's parent element within the document entity or external entity, if one exists
133
+ 3. **Document/Entity**: The base URI of the document entity or external entity containing the element
134
+
135
+ **Inheritance**: The `xml:base` scope applies to descendant elements until overridden.
136
+
137
+ .Base URI Hierarchy Example
138
+ [source,xml]
139
+ ----
140
+ <?xml version="1.0"?>
141
+ <!-- Document base: http://example.org/docs/page.xml -->
142
+ <document xml:base="http://example.org/base/">
143
+ <!-- Base URI: http://example.org/base/ -->
144
+ <section>
145
+ <!-- Base URI: http://example.org/base/ (inherited) -->
146
+ <title>Section Title</title>
147
+ <content xml:base="relative/">
148
+ <!-- Base URI: http://example.org/base/relative/ -->
149
+ <paragraph>Content here</paragraph>
150
+ <subsection xml:base="../other/">
151
+ <!-- Base URI: http://example.org/base/other/ -->
152
+ <item>Item content</item>
153
+ </subsection>
154
+ </content>
155
+ </section>
156
+ </document>
157
+ ----
158
+
159
+ === Resolution Contexts and Constraints
160
+
161
+ The base URI corresponding to a given relative URI appearing in an XML document is determined as follows:
162
+
163
+ ==== Text Content Resolution
164
+ **Rule**: The base URI for a URI reference appearing in text content is the base URI of the element containing the text.
165
+
166
+ .Text Content Example
167
+ [source,xml]
168
+ ----
169
+ <section xml:base="http://example.org/docs/">
170
+ Link to <ref>image.png</ref> <!-- Resolves to: http://example.org/docs/image.png -->
171
+ </section>
172
+ ----
173
+
174
+ ==== xml:base Attribute Resolution
175
+ **Rule**: The base URI for a URI reference appearing in an `xml:base` attribute is the base URI of the parent element of the element bearing the `xml:base` attribute, if one exists within the document entity or external entity, otherwise the base URI of the document entity or external entity containing the element.
176
+
177
+ .xml:base Resolution Example
178
+ [source,xml]
179
+ ----
180
+ <parent xml:base="http://example.org/base/">
181
+ <child xml:base="relative/path/">
182
+ <!-- child's xml:base resolves against parent's base URI -->
183
+ <!-- Result: http://example.org/base/relative/path/ -->
184
+ </child>
185
+ </parent>
186
+ ----
187
+
188
+ ==== Other Attribute Resolution
189
+ **Rule**: The base URI for a URI reference appearing in any other attribute value, including default attribute values, is the base URI of the element bearing the attribute.
190
+
191
+ .Attribute Resolution Example
192
+ [source,xml]
193
+ ----
194
+ <section xml:base="http://example.org/docs/">
195
+ <image src="photo.jpg" alt="Photo"/>
196
+ <!-- src resolves to: http://example.org/docs/photo.jpg -->
197
+ </section>
198
+ ----
199
+
200
+ ==== Processing Instruction Resolution
201
+ **Rule**: The base URI for a URI reference appearing in the content of a processing instruction is the base URI of the parent element of the processing instruction, if one exists within the document entity or external entity, otherwise the base URI of the document entity or external entity containing the processing instruction.
202
+
203
+ .Processing Instruction Example
204
+ [source,xml]
205
+ ----
206
+ <section xml:base="http://example.org/docs/">
207
+ <?xml-stylesheet href="style.css" type="text/css"?>
208
+ <!-- href resolves to: http://example.org/docs/style.css -->
209
+ </section>
210
+ ----
211
+
212
+ === Constraints and Validation Rules
213
+
214
+ ==== External Entity Constraint
215
+ [WARNING]
216
+ ====
217
+ **External DTD Default Constraint**: The presence of `xml:base` attributes might lead to unexpected results when the attribute value is provided via a default attribute from an external entity. Such declarations might not be read by software based on non-validating XML processors.
218
+ ====
219
+
220
+ **Best Practice**: `xml:base` values SHOULD be provided either:
221
+ - Directly in the XML document instance, OR
222
+ - Via default attributes declared in the internal subset of the DTD
223
+
224
+ .Problematic External Default
225
+ [source,xml]
226
+ ----
227
+ <!-- External DTD (might not be read by non-validating processors) -->
228
+ <!ATTLIST section xml:base CDATA "http://default.example.org/">
229
+
230
+ <!-- Document instance -->
231
+ <section>
232
+ <!-- xml:base default might not be applied -->
233
+ </section>
234
+ ----
235
+
236
+ .Recommended Internal Default
237
+ [source,xml]
238
+ ----
239
+ <?xml version="1.0"?>
240
+ <!DOCTYPE document [
241
+ <!ATTLIST section xml:base CDATA "http://default.example.org/">
242
+ ]>
243
+ <document>
244
+ <section>
245
+ <!-- xml:base default will be applied -->
246
+ </section>
247
+ </document>
248
+ ----
249
+
250
+ ==== Schema Validation Constraint
251
+ [CAUTION]
252
+ ====
253
+ **Schema Default Constraint**: Defaulting attributes through an external mechanism such as XML Schema may lead to unexpected results. Even if a validating processor is used, the addition of defaulted attributes subsequent to creation of the infoset can cause `xml:base` attributes to get out of sync with the [base URI] infoset property.
254
+ ====
255
+
256
+
257
+ == 4. URI Reference Encoding and Escaping
258
+
259
+ The value of an `xml:base` attribute is a Legacy Extended IRI (LEIRI) and MAY contain characters not allowed in URIs. However, some characters allowed in LEIRIs are not legal XML characters, and cannot therefore appear in `xml:base` values.
260
+
261
+ === Encoding Principles
262
+
263
+ In accordance with the principle that percent-encoding MUST occur as late as possible in the processing chain, applications which provide access to the base URI of an element SHOULD calculate and return the value without escaping.
264
+
265
+ .Example: LEIRI Handling
266
+ [source,xml]
267
+ ----
268
+ <?xml version="1.0"?>
269
+ <e1 xml:base="http://example.org/wine/">
270
+ <e2 xml:base="rosé"/>
271
+ </e1>
272
+ ----
273
+
274
+ In the example above, the base URI of element `e2` should be returned as `http://example.org/wine/rosé`.
275
+
276
+ === Character Handling Rules
277
+
278
+ 1. **Unicode Characters**: LEIRI values can contain Unicode characters that are not valid in traditional URIs
279
+ 2. **Escaping Process**:
280
+ - Convert disallowed characters to UTF-8 byte sequences
281
+ - Percent-encode the resulting bytes (e.g., `%C3%A9` for `é`)
282
+ - Use the escaped form for URI resolution operations
283
+ 3. **Return Values**: When exposing base URIs programmatically, return unescaped LEIRIs for readability
284
+
285
+ .Character Encoding Example
286
+ [source,xml]
287
+ ----
288
+ <!-- Input with Unicode characters -->
289
+ <document xml:base="http://example.org/café/">
290
+ <section xml:base="ménü.html"/>
291
+ </document>
292
+
293
+ <!-- Base URI returned: http://example.org/café/ménü.html -->
294
+ <!-- Escaped for resolution: http://example.org/caf%C3%A9/m%C3%A9n%C3%BC.html -->
295
+ ----
296
+
297
+ === Validation Constraints
298
+
299
+ [WARNING]
300
+ ====
301
+ **Invalid LEIRI Constraint**: The base URI of an element bearing an `xml:base` attribute with a value that is not a valid Legacy Extended IRI is application dependent.
302
+ ====
303
+
304
+ Applications SHOULD validate that `xml:base` values conform to LEIRI syntax before processing.
305
+
306
+
307
+ == 5. Special Cases & Implementation Notes
308
+
309
+ - `xml:base` does **not** affect:
310
+ 1. External system identifiers (like DTD system IDs)
311
+ 2. XML Namespaces declarations
312
+ 3. Non-document entities or defaulted attributes from external DTDs—especially in non‑validating processors
313
+
314
+ - Behavior of certain `xml:base` values:
315
+ 1. `xml:base=""` or values like `xml:base="#frag"` are **not** treated as resets to the document base. Processing such values is discouraged due to inconsistent handling.
316
+
317
+ - For reliability, define `xml:base` directly in the document instance or internal DTD subset—not via external entity defaults.
318
+
319
+ == 6. Conformance Requirements
320
+
321
+ To be conformant with XML Base:
322
+
323
+ - Support recognition of `xml:base` in the XML namespace context
324
+ - Accurately compute base URIs according to the hierarchy
325
+ - Correctly resolve relative URIs in all contexts (content, attributes, processing instructions)
326
+ - Handle LEIRI encoding/escaping properly
327
+ - Disregard unsupported or ambiguous cases, following spec guidance where behaviors are undefined or discouraged
328
+
329
+ == 7. Summary Table
330
+
331
+ [options="header"]
332
+ |===
333
+ | Feature | Specification Summary
334
+
335
+ | **Attribute Name & NS** | `xml:base` in `http://www.w3.org/XML/1998/namespace`
336
+
337
+ | **Value Type** | Legacy Extended IRI (LEIRI)
338
+
339
+ | **Base URI Calculation Order** | 1. `xml:base` on element
340
+ 2. Ancestor base URI
341
+ 3. Document/external entity URI
342
+ 4. Undefined/error
343
+
344
+ | **Relative URI Resolution** | Against appropriate base per context (element, attribute, etc.)
345
+
346
+ | **LEIRI Handling** | Escaped for resolution; unescaped return preferred
347
+
348
+ | **Edge Cases** | `xml:base=""` discouraged; external DTD defaults risky
349
+
350
+ | **Conformance Goals** | Accurate resolution, encoding, scoping as specified
351
+
352
+ |===
353
+
354
+ == 8. Implementation Conformance and Requirements
355
+
356
+ === Conforming XML Processors
357
+
358
+ A conforming XML processor that supports the `xml:base` specification:
359
+
360
+ 1. **MUST** recognize the `xml:base` attribute in the XML namespace (http://www.w3.org/XML/1998/namespace)
361
+ 2. **MUST** follow the base URI resolution algorithm specified in RFC 3986
362
+ 3. **MUST** handle LEIRI (Legacy Extended IRI) values as specified in this document
363
+ 4. **SHOULD** provide access to the computed base URI for each element
364
+ 5. **MAY** provide APIs for applications to access base URI information
365
+
366
+ === Processor Implementation Guidelines
367
+
368
+ ==== Base URI Calculation Requirements
369
+ - **MUST** compute base URI according to the hierarchy defined in Section 5
370
+ - **MUST** properly handle inheritance from parent to child elements
371
+ - **MUST** resolve relative `xml:base` values against the appropriate parent base URI
372
+ - **MUST** handle empty `xml:base` values correctly (application-dependent behavior)
373
+
374
+ ==== URI Resolution Requirements
375
+ - **MUST** implement RFC 3986 reference resolution algorithm
376
+ - **MUST** handle all special cases (empty string, fragment-only, query-only)
377
+ - **MUST** perform proper path merging and normalization
378
+ - **SHOULD** validate URI syntax according to RFC 3986
379
+
380
+ ==== Character Encoding Requirements
381
+ - **MUST** support LEIRI processing for `xml:base` values
382
+ - **MUST** handle Unicode characters in base URIs
383
+ - **SHOULD** provide proper percent-encoding when converting to strict URIs
384
+ - **MUST** preserve Unicode characters in computed base URIs when possible
385
+
386
+ === Error Handling Requirements
387
+
388
+ ==== Invalid xml:base Values
389
+ When an `xml:base` attribute contains an invalid LEIRI:
390
+
391
+ 1. **MUST** detect the invalid syntax
392
+ 2. **SHOULD** report the error to the application
393
+ 3. **MAY** continue processing using fallback behavior (application-dependent)
394
+ 4. **MUST NOT** cause processing to fail unless explicitly configured to do so
395
+
396
+ .Error Handling Example
397
+ [source,xml]
398
+ ----
399
+ <document xml:base="http://example.org/docs/">
400
+ <section xml:base=":::invalid:::"> <!-- Invalid URI syntax -->
401
+ <link href="page.html"/> <!-- Fallback behavior applies -->
402
+ </section>
403
+ </document>
404
+ ----
405
+
406
+ ==== Circular Base URI References
407
+ Circular references in `xml:base` values are invalid and SHOULD be detected:
408
+
409
+ **Detection Algorithm**: Implementations SHOULD track the chain of base URI resolution to detect cycles and handle them gracefully.
410
+
411
+ == 9. Security Considerations
412
+
413
+ === URI Resolution Security
414
+
415
+ ==== Malicious Base URI Injection
416
+ **Risk**: Malicious xml:base values could redirect relative URIs to unintended locations.
417
+
418
+ .Security Risk Example
419
+ [source,xml]
420
+ ----
421
+ <!-- Potentially malicious -->
422
+ <document xml:base="http://malicious.example.com/">
423
+ <script src="safe-script.js"/> <!-- Actually loads: http://malicious.example.com/safe-script.js -->
424
+ </document>
425
+ ----
426
+
427
+ **Mitigation**: Applications SHOULD validate base URIs against allowed schemes and domains.
428
+
429
+ ==== Directory Traversal Attacks
430
+ **Risk**: Relative base URIs with ".." components could access unintended file system locations.
431
+
432
+ .Directory Traversal Risk
433
+ [source,xml]
434
+ ----
435
+ <!-- File system risk -->
436
+ <config xml:base="../../../etc/">
437
+ <file href="passwd"/> <!-- Could access: /etc/passwd -->
438
+ </config>
439
+ ----
440
+
441
+ **Mitigation**:
442
+ - Validate that resolved URIs remain within expected boundaries
443
+ - Sanitize path components in file:// URIs
444
+ - Use allowlists for permitted base URI patterns
445
+
446
+ ==== Protocol Scheme Validation
447
+ **Risk**: Unexpected URI schemes in xml:base values could trigger unintended protocol handlers.
448
+
449
+ **Mitigation**: Applications SHOULD validate URI schemes and only allow expected protocols (e.g., http, https, file).
450
+
451
+ === Processing Security
452
+
453
+ ==== External Entity Considerations
454
+ When xml:base appears in external DTD subsets:
455
+ - Non-validating processors may not read external DTDs
456
+ - Default xml:base values may not be applied
457
+ - This could lead to inconsistent URI resolution behavior
458
+
459
+ **Best Practice**: Include xml:base declarations in the internal DTD subset or document instance.
460
+
461
+ ==== Resource Exhaustion
462
+ Complex xml:base hierarchies with many nested relative references could potentially cause:
463
+ - Excessive URI resolution processing
464
+ - Stack overflow in recursive resolution algorithms
465
+ - Memory exhaustion from deep element nesting
466
+
467
+ **Mitigation**: Implement reasonable limits on:
468
+ - xml:base nesting depth
469
+ - URI resolution complexity
470
+ - Processing time for URI calculations
471
+
472
+ == 10. Validation and Testing Guidelines
473
+
474
+ === Conformance Testing
475
+
476
+ ==== Required Test Scenarios
477
+ Implementations MUST handle these core scenarios correctly:
478
+
479
+ 1. **Basic Resolution**
480
+ - Simple relative URIs with xml:base
481
+ - Absolute URIs (should ignore xml:base)
482
+ - Empty relative URI (should resolve to base URI)
483
+
484
+ 2. **Hierarchical Resolution**
485
+ - Parent-child base URI inheritance
486
+ - Multiple levels of nesting
487
+ - Override scenarios
488
+
489
+ 3. **Special URI Forms**
490
+ - Fragment-only URIs (#fragment)
491
+ - Query-only URIs (?query)
492
+ - Path-only URIs (path/component)
493
+
494
+ 4. **Edge Cases**
495
+ - Empty xml:base values
496
+ - Invalid URI syntax in xml:base
497
+ - Complex relative path resolution (../, ./, etc.)
498
+
499
+ ==== Validation Algorithms
500
+
501
+ **Syntax Validation**: xml:base values MUST be validated as LEIRI references:
502
+
503
+ .Validation Steps
504
+ [source,text]
505
+ ----
506
+ 1. Check XML character legality
507
+ 2. Parse as LEIRI reference
508
+ 3. Validate component syntax
509
+ 4. Check for prohibited characters
510
+ 5. Verify relative/absolute form appropriateness
511
+ ----
512
+
513
+ **Resolution Validation**: Resolved URIs MUST be valid:
514
+ - Result MUST be absolute URI or valid relative reference
515
+ - Path components MUST be properly normalized
516
+ - Character encoding MUST be consistent
517
+
518
+ === Testing Frameworks
519
+
520
+ ==== Unit Test Categories
521
+ **Positive Tests**: Valid scenarios that should work correctly
522
+ **Negative Tests**: Invalid scenarios that should fail gracefully
523
+ **Edge Case Tests**: Boundary conditions and unusual but valid scenarios
524
+ **Performance Tests**: Large documents, deep nesting, complex resolution
525
+
526
+ .Sample Test Case
527
+ [source,xml]
528
+ ----
529
+ <!-- Test: Nested relative base URIs -->
530
+ <test-case name="nested-relative-bases">
531
+ <input>
532
+ <document xml:base="http://example.org/a/b/">
533
+ <section xml:base="../c/">
534
+ <item href="d.xml"/>
535
+ </section>
536
+ </document>
537
+ </input>
538
+ <expected-result>
539
+ <resolved-uri>http://example.org/a/c/d.xml</resolved-uri>
540
+ </expected-result>
541
+ </test-case>
542
+ ----
543
+
544
+ ==== Interoperability Testing
545
+ - Test against multiple XML parsers
546
+ - Verify consistent behavior across implementations
547
+ - Check handling of edge cases and error conditions
548
+ - Validate performance characteristics
549
+
550
+ == 11. Examples and Use Cases
551
+
552
+ === Content Management Systems
553
+
554
+ .Document Collection Management
555
+ [source,xml]
556
+ ----
557
+ <?xml version="1.0"?>
558
+ <publication xml:base="https://docs.example.org/2024/manual/">
559
+ <metadata>
560
+ <stylesheet href="../common/styles.css"/> <!-- https://docs.example.org/2024/common/styles.css -->
561
+ <logo src="../images/logo.png"/> <!-- https://docs.example.org/2024/images/logo.png -->
562
+ </metadata>
563
+
564
+ <chapter xml:base="chapter1/">
565
+ <title>Introduction</title>
566
+ <content src="intro.xml"/> <!-- https://docs.example.org/2024/manual/chapter1/intro.xml -->
567
+ <figures xml:base="figures/">
568
+ <figure src="diagram.svg"/> <!-- https://docs.example.org/2024/manual/chapter1/figures/diagram.svg -->
569
+ </figures>
570
+ </chapter>
571
+
572
+ <chapter xml:base="chapter2/">
573
+ <title>Advanced Topics</title>
574
+ <content src="advanced.xml"/> <!-- https://docs.example.org/2024/manual/chapter2/advanced.xml -->
575
+ </chapter>
576
+ </publication>
577
+ ----
578
+
579
+ === Web Service Configuration
580
+
581
+ .RESTful API Configuration
582
+ [source,xml]
583
+ ----
584
+ <?xml version="1.0"?>
585
+ <api-specification xml:base="https://api.service.com/v2/">
586
+ <authentication>
587
+ <login href="auth/login"/> <!-- https://api.service.com/v2/auth/login -->
588
+ <logout href="auth/logout"/> <!-- https://api.service.com/v2/auth/logout -->
589
+ </authentication>
590
+
591
+ <resources xml:base="data/">
592
+ <users href="users/"/> <!-- https://api.service.com/v2/data/users/ -->
593
+ <orders href="orders/"/> <!-- https://api.service.com/v2/data/orders/ -->
594
+
595
+ <reports xml:base="../reports/">
596
+ <sales href="sales.json"/> <!-- https://api.service.com/v2/reports/sales.json -->
597
+ <inventory href="inventory.json"/> <!-- https://api.service.com/v2/reports/inventory.json -->
598
+ </reports>
599
+ </resources>
600
+
601
+ <documentation xml:base="https://docs.service.com/">
602
+ <api-guide href="api-guide.html"/> <!-- https://docs.service.com/api-guide.html -->
603
+ <examples href="examples/"/> <!-- https://docs.service.com/examples/ -->
604
+ </documentation>
605
+ </api-specification>
606
+ ----
607
+
608
+ === Multimedia Document Structure
609
+
610
+ .Media Asset Organization
611
+ [source,xml]
612
+ ----
613
+ <?xml version="1.0"?>
614
+ <presentation xml:base="https://media.example.org/conference2024/">
615
+ <slide id="intro" xml:base="slides/intro/">
616
+ <background src="background.jpg"/> <!-- https://media.example.org/conference2024/slides/intro/background.jpg -->
617
+ <audio src="narration.mp3"/> <!-- https://media.example.org/conference2024/slides/intro/narration.mp3 -->
618
+
619
+ <assets xml:base="../../common/icons/">
620
+ <logo src="company-logo.svg"/> <!-- https://media.example.org/conference2024/common/icons/company-logo.svg -->
621
+ <bullet src="bullet-point.png"/> <!-- https://media.example.org/conference2024/common/icons/bullet-point.png -->
622
+ </assets>
623
+ </slide>
624
+
625
+ <slide id="demo" xml:base="slides/demo/">
626
+ <video>
627
+ <source src="demo.mp4"/> <!-- https://media.example.org/conference2024/slides/demo/demo.mp4 -->
628
+ <subtitles src="subtitles.vtt"/> <!-- https://media.example.org/conference2024/slides/demo/subtitles.vtt -->
629
+ </video>
630
+ </slide>
631
+ </presentation>
632
+ ----
633
+
634
+ == 12. Advanced Implementation Topics
635
+
636
+ === Performance Considerations
637
+
638
+ ==== Caching Strategies
639
+ **Base URI Computation**: Since base URIs follow a hierarchical pattern, implementations can optimize by:
640
+
641
+ 1. **Caching computed base URIs** for elements
642
+ 2. **Invalidating cache** when xml:base attributes change
643
+ 3. **Sharing base URIs** among sibling elements
644
+
645
+ ==== Lazy Evaluation
646
+ **Deferred Resolution**: Base URI resolution can be deferred until actually needed:
647
+ - Store xml:base values without immediate resolution
648
+ - Compute full base URI only when applications request it
649
+ - Cache results for subsequent requests
650
+
651
+ === Integration with Other Technologies
652
+
653
+ ==== HTML Base Element Interaction
654
+ When XML is processed in web browsers:
655
+ - HTML `<base>` element may affect XML document processing
656
+ - `xml:base` takes precedence within XML content
657
+ - Careful consideration needed for mixed HTML/XML documents
658
+
659
+ ==== XPath and XSLT Integration
660
+ **XPath Functions**: `xml:base` affects URI resolution in:
661
+ - `document()` function calls
662
+ - `xsl:import` and `xsl:include` href attributes
663
+ - Any XPath expression resolving relative URIs
664
+
665
+ .XSLT Integration Example
666
+ [source,xml]
667
+ ----
668
+ <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
669
+ <root xml:base="http://example.org/data/">
670
+ <xsl:variable name="data" select="document('source.xml')"/>
671
+ <!-- source.xml resolves to: http://example.org/data/source.xml -->
672
+ </root>
673
+ </xsl:stylesheet>
674
+ ----
675
+
676
+ === Internationalization Support
677
+
678
+ ==== Unicode Normalization
679
+ **Character Processing**: When handling Unicode in `xml:base` values:
680
+ - Consider Unicode normalization forms (NFC, NFD, NFKC, NFKD)
681
+ - Maintain consistency with URI percent-encoding rules
682
+ - Handle bidirectional text appropriately
683
+
684
+ ==== Locale-Specific Considerations
685
+ - Case folding rules may vary by locale
686
+ - Character equivalence rules may differ
687
+ - Domain name internationalization (IDN) integration
688
+
689
+ .Unicode Example
690
+ [source,xml]
691
+ <?xml version="1.0" encoding="UTF-8"?>
692
+ <document xml:base="http://例え.テスト/documents/">
693
+ <!-- Japanese domain name in xml:base -->
694
+ <file href="ファイル.xml"/> <!-- Unicode filename -->
695
+ </document>
696
+
697
+ == Implementation Status in lutaml-model
698
+
699
+ [cols="1,1,1", options="header"]
700
+ |===
701
+ | Feature/Requirement | Status | Notes
702
+
703
+ | Recognize `xml:base` attribute in XML namespace | Not implemented | No dedicated xml:base attribute detection
704
+ | Base URI calculation hierarchy (element, ancestor, document/entity) | Not implemented | No base URI resolution logic
705
+ | Relative URI resolution using xml:base | Not implemented | No support for resolving relative URIs via xml:base
706
+ | LEIRI (Legacy Extended IRI) value handling | Not implemented | No LEIRI parsing or encoding/escaping logic
707
+ | Inheritance of base URI to descendants | Not implemented | No inheritance or override logic for xml:base
708
+ | Handling of xml:base in attributes, processing instructions | Not implemented | No context-aware base URI resolution
709
+ | Error handling for invalid xml:base values | Not implemented | No detection or reporting of invalid LEIRI
710
+ | Security checks (malicious base URI, traversal, scheme validation) | Not implemented | No security validation for base URIs
711
+ | Caching or lazy evaluation of base URIs | Not implemented | No caching or deferred resolution
712
+ | Integration with XPath/XSLT/document() | Not implemented | No integration with XPath/XSLT URI resolution
713
+ | Unicode normalization and internationalization | Not implemented | No Unicode normalization or IDN support
714
+ | Conformance testing and validation | Not implemented | No unit tests or validation for xml:base features
715
+ | Documentation of supported features/conformance | Not implemented | No documentation of xml:base support
716
+ |===
717
+
718
+ *Summary*: lutaml-model does not currently implement any XML Base (`xml:base`) features, base URI resolution, or related validation, encoding, or security logic. All XML Base requirements are unimplemented as of this review.