uss-xsd-engine 0.1.0-rc.1 → 0.1.0
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/README.md +3 -0
- package/dist/uss-xsd-engine.esm.js +54 -8
- package/dist/uss-xsd-engine.standalone.js +54 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -5,6 +5,9 @@ Browser-first XSD engine for schema diagnostics, tree extraction, sample XML gen
|
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|

|
|
8
|
+

|
|
9
|
+

|
|
10
|
+

|
|
8
11
|
[](https://www.jsdelivr.com/package/npm/uss-xsd-engine)
|
|
9
12
|
|
|
10
13
|
---
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* uss-xsd-engine v0.1.0
|
|
2
|
+
* uss-xsd-engine v0.1.0
|
|
3
3
|
* (c) 2026 Bernard Mumble
|
|
4
4
|
* MIT License
|
|
5
5
|
*/
|
|
@@ -583,6 +583,33 @@ function lookupInImportedSchemas(bucketName, schema, namespaceUri3, localName3,
|
|
|
583
583
|
}
|
|
584
584
|
return null;
|
|
585
585
|
}
|
|
586
|
+
function lookupInImportedSchemasForUnprefixed(bucketName, schema, localName3, visited = /* @__PURE__ */ new Set()) {
|
|
587
|
+
if (!schema || !localName3) return null;
|
|
588
|
+
if (visited.has(schema)) return null;
|
|
589
|
+
visited.add(schema);
|
|
590
|
+
const targetNs = schema.targetNamespace || null;
|
|
591
|
+
for (const importedSchema of schema.importedSchemas || []) {
|
|
592
|
+
if (!importedSchema) continue;
|
|
593
|
+
const importedNs = importedSchema.targetNamespace || null;
|
|
594
|
+
if (importedNs === targetNs) {
|
|
595
|
+
const direct = lookupInSchemaBucket(
|
|
596
|
+
bucketName,
|
|
597
|
+
importedSchema,
|
|
598
|
+
importedNs,
|
|
599
|
+
localName3
|
|
600
|
+
);
|
|
601
|
+
if (direct) return direct;
|
|
602
|
+
}
|
|
603
|
+
const nested = lookupInImportedSchemasForUnprefixed(
|
|
604
|
+
bucketName,
|
|
605
|
+
importedSchema,
|
|
606
|
+
localName3,
|
|
607
|
+
visited
|
|
608
|
+
);
|
|
609
|
+
if (nested) return nested;
|
|
610
|
+
}
|
|
611
|
+
return null;
|
|
612
|
+
}
|
|
586
613
|
function lookupByQName(bucketName, schema, name) {
|
|
587
614
|
if (!schema || !name) return null;
|
|
588
615
|
const parsed = parseQName(name);
|
|
@@ -615,6 +642,12 @@ function lookupByQName(bucketName, schema, name) {
|
|
|
615
642
|
localName3
|
|
616
643
|
);
|
|
617
644
|
if (hostNamespaceDecl) return hostNamespaceDecl;
|
|
645
|
+
const importedSameNamespaceDecl = lookupInImportedSchemasForUnprefixed(
|
|
646
|
+
bucketName,
|
|
647
|
+
schema,
|
|
648
|
+
localName3
|
|
649
|
+
);
|
|
650
|
+
if (importedSameNamespaceDecl) return importedSameNamespaceDecl;
|
|
618
651
|
}
|
|
619
652
|
return null;
|
|
620
653
|
}
|
|
@@ -1524,7 +1557,7 @@ function parseAttributeGroup(node, xsdText, lineStarts, parentPath, schema, issu
|
|
|
1524
1557
|
});
|
|
1525
1558
|
}
|
|
1526
1559
|
function getEffectiveTargetNamespace(schemaRoot, options = {}) {
|
|
1527
|
-
if (Object.prototype.hasOwnProperty.call(options, "_overrideTargetNamespace")) {
|
|
1560
|
+
if (Object.prototype.hasOwnProperty.call(options, "_overrideTargetNamespace") && options._overrideTargetNamespace !== void 0) {
|
|
1528
1561
|
return options._overrideTargetNamespace;
|
|
1529
1562
|
}
|
|
1530
1563
|
return schemaRoot.getAttribute("targetNamespace");
|
|
@@ -1535,12 +1568,12 @@ function isIncludeNamespaceCompatible(hostSchema, includedSchema) {
|
|
|
1535
1568
|
return hostNs === includedNs;
|
|
1536
1569
|
}
|
|
1537
1570
|
function isImportNamespaceCompatible(ref, importedSchema) {
|
|
1538
|
-
const declaredNs = ref
|
|
1539
|
-
const importedNs = importedSchema
|
|
1571
|
+
const declaredNs = ref && Object.prototype.hasOwnProperty.call(ref, "namespace") ? ref.namespace : null;
|
|
1572
|
+
const importedNs = importedSchema && Object.prototype.hasOwnProperty.call(importedSchema, "targetNamespace") ? importedSchema.targetNamespace : null;
|
|
1540
1573
|
if (!declaredNs) {
|
|
1541
1574
|
return true;
|
|
1542
1575
|
}
|
|
1543
|
-
return declaredNs === importedNs;
|
|
1576
|
+
return (declaredNs || null) === (importedNs || null);
|
|
1544
1577
|
}
|
|
1545
1578
|
function buildSchemaModel(doc, options = {}) {
|
|
1546
1579
|
const issues = [];
|
|
@@ -1775,16 +1808,21 @@ function buildSchemaModel(doc, options = {}) {
|
|
|
1775
1808
|
continue;
|
|
1776
1809
|
}
|
|
1777
1810
|
const externalRoot = getSchemaRoot(externalDoc);
|
|
1778
|
-
const externalDeclaredTargetNamespace = externalRoot?.
|
|
1811
|
+
const externalDeclaredTargetNamespace = externalRoot?.hasAttribute(
|
|
1812
|
+
"targetNamespace"
|
|
1813
|
+
) ? externalRoot.getAttribute("targetNamespace") : null;
|
|
1779
1814
|
const shouldApplyChameleonInclude = ref.kind === "include" && externalDeclaredTargetNamespace === null;
|
|
1780
1815
|
const externalBuild = buildSchemaModel(externalDoc, {
|
|
1781
1816
|
...options,
|
|
1782
1817
|
xsdText: externalXsdText,
|
|
1783
1818
|
externalDocuments,
|
|
1784
1819
|
_visitedExternalSchemas: visited,
|
|
1785
|
-
|
|
1820
|
+
...shouldApplyChameleonInclude ? { _overrideTargetNamespace: schema.targetNamespace } : {}
|
|
1786
1821
|
});
|
|
1787
1822
|
if (externalBuild.schema) {
|
|
1823
|
+
if (ref.kind === "import") {
|
|
1824
|
+
schema.importedSchemas.push(externalBuild.schema);
|
|
1825
|
+
}
|
|
1788
1826
|
if (ref.kind === "include") {
|
|
1789
1827
|
if (!isIncludeNamespaceCompatible(schema, externalBuild.schema)) {
|
|
1790
1828
|
issues.push(
|
|
@@ -2402,7 +2440,7 @@ function runSchemaDiagnostics(schema, options = {}) {
|
|
|
2402
2440
|
}
|
|
2403
2441
|
|
|
2404
2442
|
// src/version.js
|
|
2405
|
-
var ENGINE_VERSION = "v0.1.0
|
|
2443
|
+
var ENGINE_VERSION = "v0.1.0";
|
|
2406
2444
|
|
|
2407
2445
|
// src/utils/result.js
|
|
2408
2446
|
function summarizeIssues(issues = []) {
|
|
@@ -3399,6 +3437,14 @@ function generateXmlFromSchema(schema, options = {}, helpers = {}) {
|
|
|
3399
3437
|
state,
|
|
3400
3438
|
true
|
|
3401
3439
|
);
|
|
3440
|
+
if (rootNode) {
|
|
3441
|
+
const finalNsAttrs = buildRootNamespaceAttributes(schema, root, state);
|
|
3442
|
+
rootNode.attributes = {
|
|
3443
|
+
...finalNsAttrs,
|
|
3444
|
+
...rootNode.attributes
|
|
3445
|
+
// preserve any existing attrs
|
|
3446
|
+
};
|
|
3447
|
+
}
|
|
3402
3448
|
return {
|
|
3403
3449
|
rootElementName: root.name,
|
|
3404
3450
|
rootNode
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* uss-xsd-engine v0.1.0
|
|
2
|
+
* uss-xsd-engine v0.1.0
|
|
3
3
|
* (c) 2026 Bernard Mumble
|
|
4
4
|
* MIT License
|
|
5
5
|
*/
|
|
@@ -610,6 +610,33 @@ var UssXsdEngine = (() => {
|
|
|
610
610
|
}
|
|
611
611
|
return null;
|
|
612
612
|
}
|
|
613
|
+
function lookupInImportedSchemasForUnprefixed(bucketName, schema, localName3, visited = /* @__PURE__ */ new Set()) {
|
|
614
|
+
if (!schema || !localName3) return null;
|
|
615
|
+
if (visited.has(schema)) return null;
|
|
616
|
+
visited.add(schema);
|
|
617
|
+
const targetNs = schema.targetNamespace || null;
|
|
618
|
+
for (const importedSchema of schema.importedSchemas || []) {
|
|
619
|
+
if (!importedSchema) continue;
|
|
620
|
+
const importedNs = importedSchema.targetNamespace || null;
|
|
621
|
+
if (importedNs === targetNs) {
|
|
622
|
+
const direct = lookupInSchemaBucket(
|
|
623
|
+
bucketName,
|
|
624
|
+
importedSchema,
|
|
625
|
+
importedNs,
|
|
626
|
+
localName3
|
|
627
|
+
);
|
|
628
|
+
if (direct) return direct;
|
|
629
|
+
}
|
|
630
|
+
const nested = lookupInImportedSchemasForUnprefixed(
|
|
631
|
+
bucketName,
|
|
632
|
+
importedSchema,
|
|
633
|
+
localName3,
|
|
634
|
+
visited
|
|
635
|
+
);
|
|
636
|
+
if (nested) return nested;
|
|
637
|
+
}
|
|
638
|
+
return null;
|
|
639
|
+
}
|
|
613
640
|
function lookupByQName(bucketName, schema, name) {
|
|
614
641
|
if (!schema || !name) return null;
|
|
615
642
|
const parsed = parseQName(name);
|
|
@@ -642,6 +669,12 @@ var UssXsdEngine = (() => {
|
|
|
642
669
|
localName3
|
|
643
670
|
);
|
|
644
671
|
if (hostNamespaceDecl) return hostNamespaceDecl;
|
|
672
|
+
const importedSameNamespaceDecl = lookupInImportedSchemasForUnprefixed(
|
|
673
|
+
bucketName,
|
|
674
|
+
schema,
|
|
675
|
+
localName3
|
|
676
|
+
);
|
|
677
|
+
if (importedSameNamespaceDecl) return importedSameNamespaceDecl;
|
|
645
678
|
}
|
|
646
679
|
return null;
|
|
647
680
|
}
|
|
@@ -1551,7 +1584,7 @@ var UssXsdEngine = (() => {
|
|
|
1551
1584
|
});
|
|
1552
1585
|
}
|
|
1553
1586
|
function getEffectiveTargetNamespace(schemaRoot, options = {}) {
|
|
1554
|
-
if (Object.prototype.hasOwnProperty.call(options, "_overrideTargetNamespace")) {
|
|
1587
|
+
if (Object.prototype.hasOwnProperty.call(options, "_overrideTargetNamespace") && options._overrideTargetNamespace !== void 0) {
|
|
1555
1588
|
return options._overrideTargetNamespace;
|
|
1556
1589
|
}
|
|
1557
1590
|
return schemaRoot.getAttribute("targetNamespace");
|
|
@@ -1562,12 +1595,12 @@ var UssXsdEngine = (() => {
|
|
|
1562
1595
|
return hostNs === includedNs;
|
|
1563
1596
|
}
|
|
1564
1597
|
function isImportNamespaceCompatible(ref, importedSchema) {
|
|
1565
|
-
const declaredNs = ref
|
|
1566
|
-
const importedNs = importedSchema
|
|
1598
|
+
const declaredNs = ref && Object.prototype.hasOwnProperty.call(ref, "namespace") ? ref.namespace : null;
|
|
1599
|
+
const importedNs = importedSchema && Object.prototype.hasOwnProperty.call(importedSchema, "targetNamespace") ? importedSchema.targetNamespace : null;
|
|
1567
1600
|
if (!declaredNs) {
|
|
1568
1601
|
return true;
|
|
1569
1602
|
}
|
|
1570
|
-
return declaredNs === importedNs;
|
|
1603
|
+
return (declaredNs || null) === (importedNs || null);
|
|
1571
1604
|
}
|
|
1572
1605
|
function buildSchemaModel(doc, options = {}) {
|
|
1573
1606
|
const issues = [];
|
|
@@ -1802,16 +1835,21 @@ var UssXsdEngine = (() => {
|
|
|
1802
1835
|
continue;
|
|
1803
1836
|
}
|
|
1804
1837
|
const externalRoot = getSchemaRoot(externalDoc);
|
|
1805
|
-
const externalDeclaredTargetNamespace = externalRoot?.
|
|
1838
|
+
const externalDeclaredTargetNamespace = externalRoot?.hasAttribute(
|
|
1839
|
+
"targetNamespace"
|
|
1840
|
+
) ? externalRoot.getAttribute("targetNamespace") : null;
|
|
1806
1841
|
const shouldApplyChameleonInclude = ref.kind === "include" && externalDeclaredTargetNamespace === null;
|
|
1807
1842
|
const externalBuild = buildSchemaModel(externalDoc, {
|
|
1808
1843
|
...options,
|
|
1809
1844
|
xsdText: externalXsdText,
|
|
1810
1845
|
externalDocuments,
|
|
1811
1846
|
_visitedExternalSchemas: visited,
|
|
1812
|
-
|
|
1847
|
+
...shouldApplyChameleonInclude ? { _overrideTargetNamespace: schema.targetNamespace } : {}
|
|
1813
1848
|
});
|
|
1814
1849
|
if (externalBuild.schema) {
|
|
1850
|
+
if (ref.kind === "import") {
|
|
1851
|
+
schema.importedSchemas.push(externalBuild.schema);
|
|
1852
|
+
}
|
|
1815
1853
|
if (ref.kind === "include") {
|
|
1816
1854
|
if (!isIncludeNamespaceCompatible(schema, externalBuild.schema)) {
|
|
1817
1855
|
issues.push(
|
|
@@ -2429,7 +2467,7 @@ var UssXsdEngine = (() => {
|
|
|
2429
2467
|
}
|
|
2430
2468
|
|
|
2431
2469
|
// src/version.js
|
|
2432
|
-
var ENGINE_VERSION = "v0.1.0
|
|
2470
|
+
var ENGINE_VERSION = "v0.1.0";
|
|
2433
2471
|
|
|
2434
2472
|
// src/utils/result.js
|
|
2435
2473
|
function summarizeIssues(issues = []) {
|
|
@@ -3426,6 +3464,14 @@ var UssXsdEngine = (() => {
|
|
|
3426
3464
|
state,
|
|
3427
3465
|
true
|
|
3428
3466
|
);
|
|
3467
|
+
if (rootNode) {
|
|
3468
|
+
const finalNsAttrs = buildRootNamespaceAttributes(schema, root, state);
|
|
3469
|
+
rootNode.attributes = {
|
|
3470
|
+
...finalNsAttrs,
|
|
3471
|
+
...rootNode.attributes
|
|
3472
|
+
// preserve any existing attrs
|
|
3473
|
+
};
|
|
3474
|
+
}
|
|
3429
3475
|
return {
|
|
3430
3476
|
rootElementName: root.name,
|
|
3431
3477
|
rootNode
|
package/package.json
CHANGED