uss-xsd-engine 0.1.0-beta.2
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.
- package/LICENSE +21 -0
- package/README.md +283 -0
- package/dist/uss-xsd-engine.esm.js +4149 -0
- package/dist/uss-xsd-engine.standalone.js +4172 -0
- package/package.json +37 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Bernard Mumble
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
# uss-xsd-engine
|
|
2
|
+
|
|
3
|
+
Browser-first XSD engine for schema diagnostics, tree extraction, sample XML generation, and XML validation.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## ๐ Overview
|
|
8
|
+
|
|
9
|
+
`uss-xsd-engine` is a standalone JavaScript engine designed to process XML Schema (XSD) directly in the browser.
|
|
10
|
+
|
|
11
|
+
It is built to power tools like USS XSD Studio while remaining lightweight, dependency-free, and reusable as:
|
|
12
|
+
|
|
13
|
+
- a browser/CDN script
|
|
14
|
+
- an npm package
|
|
15
|
+
- an embedded validation/generation engine
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## โจ Features
|
|
20
|
+
|
|
21
|
+
### โ
Schema Processing
|
|
22
|
+
- Parse XSD into a structured internal model
|
|
23
|
+
- Namespace-aware schema resolution
|
|
24
|
+
- Support for global elements, types, groups, and attribute groups
|
|
25
|
+
|
|
26
|
+
### โ
Schema Diagnostics
|
|
27
|
+
- Unknown types and references detection
|
|
28
|
+
- Missing base types
|
|
29
|
+
- Restriction validation (subset + occurrence narrowing)
|
|
30
|
+
- Facet validation (including pattern support for date/time)
|
|
31
|
+
- Default/fixed conflict detection
|
|
32
|
+
- Include/import diagnostics
|
|
33
|
+
|
|
34
|
+
### โ
Schema Tree Extraction
|
|
35
|
+
- Semantic tree representation of XSD
|
|
36
|
+
- Expandable references and structure traversal
|
|
37
|
+
- Useful for UI rendering and schema exploration
|
|
38
|
+
|
|
39
|
+
### โ
Sample XML Generation
|
|
40
|
+
- Minimal (mandatory-only) mode
|
|
41
|
+
- Full traversal (limited expansion)
|
|
42
|
+
- Namespace-aware output (`xmlns`, prefixes)
|
|
43
|
+
- Supports:
|
|
44
|
+
- sequences
|
|
45
|
+
- choices (first-branch strategy)
|
|
46
|
+
- extensions
|
|
47
|
+
- restrictions (first-pass)
|
|
48
|
+
- Honors:
|
|
49
|
+
- `fixed` values
|
|
50
|
+
- `default` values
|
|
51
|
+
|
|
52
|
+
### โ
XML Validation
|
|
53
|
+
- Validate XML against XSD structure
|
|
54
|
+
- Namespace-aware validation
|
|
55
|
+
- Content model validation:
|
|
56
|
+
- sequence
|
|
57
|
+
- choice
|
|
58
|
+
- all
|
|
59
|
+
- Mixed content enforcement
|
|
60
|
+
- Attribute validation
|
|
61
|
+
- Facet validation (pattern, length, numeric, etc.)
|
|
62
|
+
- Restriction enforcement (runtime)
|
|
63
|
+
- Fixed value enforcement
|
|
64
|
+
|
|
65
|
+
### โ
Include / Import (Groundwork)
|
|
66
|
+
- Recognizes `xs:include` and `xs:import`
|
|
67
|
+
- Supports caller-provided external schemas
|
|
68
|
+
- Merges external schema definitions into runtime model
|
|
69
|
+
- Emits warnings when referenced schemas are not provided
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
## ๐ฆ Installation
|
|
74
|
+
|
|
75
|
+
### npm
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
npm install uss-xsd-engine
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
```JavaScript
|
|
82
|
+
import {
|
|
83
|
+
getSchemaDiagnostics,
|
|
84
|
+
extractSchemaTree,
|
|
85
|
+
generateSampleXml,
|
|
86
|
+
validateXml
|
|
87
|
+
} from "uss-xsd-engine";
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### CDN/Browser
|
|
91
|
+
|
|
92
|
+
```HTML
|
|
93
|
+
<script src="https://unpkg.com/uss-xsd-engine@0.1.0-beta.1/dist/uss-xsd-engine.standalone.js"></script>
|
|
94
|
+
|
|
95
|
+
<script>
|
|
96
|
+
const result = UssXsdEngine.getSchemaDiagnostics({ xsdText });
|
|
97
|
+
</script>
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Public API
|
|
101
|
+
All endpoints follow a consistant result format:
|
|
102
|
+
|
|
103
|
+
```JavaScript
|
|
104
|
+
{
|
|
105
|
+
ok: boolean,
|
|
106
|
+
data: any,
|
|
107
|
+
issues: Issue[],
|
|
108
|
+
summary: {
|
|
109
|
+
errorCount: number,
|
|
110
|
+
warningCount: number,
|
|
111
|
+
infoCount: number
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
`getSchemaDiagnostics({ xsdText, options? })`
|
|
119
|
+
Analyze schema and return:
|
|
120
|
+
|
|
121
|
+
- issues (errors/warnings)
|
|
122
|
+
- roots
|
|
123
|
+
- supported/unsupported features
|
|
124
|
+
- schema statistics
|
|
125
|
+
|
|
126
|
+
---
|
|
127
|
+
|
|
128
|
+
`extractSchemaTree({ xsdText, options? })`
|
|
129
|
+
Returns a structured tree respresentation of the schema
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
`generateSampleXml({ xsdText, options? })`
|
|
134
|
+
|
|
135
|
+
Generates example XML from XSD.
|
|
136
|
+
|
|
137
|
+
- Options:
|
|
138
|
+
- `mode`: `"minimal"` (default) or `"full"`
|
|
139
|
+
- `targetPrefix`: namespace prefix (default `"tns"`)
|
|
140
|
+
- `includeOptionalAttributes`: boolean
|
|
141
|
+
- `externalDocuments`: map of schemaLocation โ XSD text
|
|
142
|
+
|
|
143
|
+
---
|
|
144
|
+
|
|
145
|
+
`validateXml({ xsdText, xmlText, options? })`
|
|
146
|
+
|
|
147
|
+
Validates XML against schema.
|
|
148
|
+
|
|
149
|
+
Options:
|
|
150
|
+
- `rootElementName`
|
|
151
|
+
- `externalDocuments`
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
### ๐ External Schema Support
|
|
156
|
+
|
|
157
|
+
You can provide external schemas manually:
|
|
158
|
+
|
|
159
|
+
```JavaScript
|
|
160
|
+
const externalDocuments = {
|
|
161
|
+
"common.xsd": "...",
|
|
162
|
+
"common-import.xsd": "..."
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
validateXml({
|
|
166
|
+
xsdText,
|
|
167
|
+
xmlText,
|
|
168
|
+
options: {
|
|
169
|
+
externalDocuments
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
---
|
|
175
|
+
|
|
176
|
+
## โ ๏ธ Supported vs Not Fully Supported
|
|
177
|
+
### โ
Supported (v0.1.x)
|
|
178
|
+
- Most common XSD structures
|
|
179
|
+
- Namespace-aware resolution
|
|
180
|
+
- Extensions (`xs:extension`)
|
|
181
|
+
- Restrictions (subset + occurrence checks)
|
|
182
|
+
- Facet validation (including pattern)
|
|
183
|
+
- Default / fixed semantics
|
|
184
|
+
- Include/import (manual provision)
|
|
185
|
+
- Sample XML generation (practical coverage)
|
|
186
|
+
- XML validation (core structure + facets)
|
|
187
|
+
|
|
188
|
+
---
|
|
189
|
+
|
|
190
|
+
## โ ๏ธ Partially Supported / In Progress
|
|
191
|
+
- Deep sample XML expansion (choice branching, recursion depth)
|
|
192
|
+
- Full restriction theorem validation (advanced edge cases)
|
|
193
|
+
- Namespace preservation strategies in generation
|
|
194
|
+
- Advanced wildcard (`xs:any`, `xs:anyAttribute`)
|
|
195
|
+
- Attribute namespace qualification
|
|
196
|
+
- Recursive include/import graph resolution
|
|
197
|
+
|
|
198
|
+
---
|
|
199
|
+
|
|
200
|
+
## โ Not Supported Yet
|
|
201
|
+
- Identity constraints (`xs:key`, `xs:keyref`, `xs:unique`)
|
|
202
|
+
- Automatic network fetching of schemas
|
|
203
|
+
- Full W3C spec conformance (edge-case completeness)
|
|
204
|
+
- Streaming validation for very large XML
|
|
205
|
+
- Chameleon includes
|
|
206
|
+
|
|
207
|
+
---
|
|
208
|
+
|
|
209
|
+
## ๐งช Playground
|
|
210
|
+
|
|
211
|
+
The repository includes `playground.html` for:
|
|
212
|
+
|
|
213
|
+
- testing schemas
|
|
214
|
+
- validating XML
|
|
215
|
+
- generating sample XML
|
|
216
|
+
- debugging diagnostics
|
|
217
|
+
|
|
218
|
+
The playground uses the built bundle to simulate real-world usage.
|
|
219
|
+
|
|
220
|
+
---
|
|
221
|
+
|
|
222
|
+
## ๐งฑ Architecture
|
|
223
|
+
|
|
224
|
+
```ruby
|
|
225
|
+
src/
|
|
226
|
+
api/
|
|
227
|
+
parser/
|
|
228
|
+
model/
|
|
229
|
+
resolver/
|
|
230
|
+
validation/
|
|
231
|
+
generator/
|
|
232
|
+
tree/
|
|
233
|
+
diagnostics/
|
|
234
|
+
utils/
|
|
235
|
+
```
|
|
236
|
+
Design principles:
|
|
237
|
+
- browser-first
|
|
238
|
+
- dependency-light
|
|
239
|
+
- layered architecture
|
|
240
|
+
- shared semantic model across all features
|
|
241
|
+
|
|
242
|
+
---
|
|
243
|
+
|
|
244
|
+
## ๐ฃ๏ธ Roadmap
|
|
245
|
+
### Near-term
|
|
246
|
+
- Recursive include/import resolution
|
|
247
|
+
- Improved sample XML depth traversal
|
|
248
|
+
- Restriction enforcement (advanced cases)
|
|
249
|
+
- Better namespace output strategies
|
|
250
|
+
|
|
251
|
+
### Mid-term
|
|
252
|
+
- Identity constraints (key/keyref)
|
|
253
|
+
- Advanced wildcard handling
|
|
254
|
+
- Performance optimizations
|
|
255
|
+
|
|
256
|
+
### Long-term
|
|
257
|
+
- Full XSD spec coverage
|
|
258
|
+
- Streaming validation
|
|
259
|
+
- USS Pro / hosted engine capabilities
|
|
260
|
+
|
|
261
|
+
---
|
|
262
|
+
|
|
263
|
+
## ๐ Versioning
|
|
264
|
+
|
|
265
|
+
This project follows incremental feature delivery:
|
|
266
|
+
|
|
267
|
+
`0.1.x` โ foundational engine (current phase)
|
|
268
|
+
`0.2.x` โ expanded spec coverage
|
|
269
|
+
`1.0.0` โ stable production-ready engine
|
|
270
|
+
|
|
271
|
+
---
|
|
272
|
+
|
|
273
|
+
## ๐ค Contributing
|
|
274
|
+
|
|
275
|
+
This project is currently evolving rapidly. Contributions and feedback are welcome.
|
|
276
|
+
|
|
277
|
+
---
|
|
278
|
+
|
|
279
|
+
## ๐ License
|
|
280
|
+
|
|
281
|
+
MIT
|
|
282
|
+
|
|
283
|
+
---
|