xi include part 1

This commit is contained in:
2026-08-01 14:30:14 +02:00
parent 656fab349d
commit 429ea367f3
7 changed files with 345 additions and 36 deletions
+26
View File
@@ -216,3 +216,29 @@ test("top-level asset ids with plain pipeline ids are not references", () => {
0,
);
});
test("xi:include elements are outside the XSD model and unvalidated", () => {
// The nested XInclude inside a GameObject draw list (HeadlightDraw2.xml)
// must resolve to no XSD type, so href/xpointer can never be flagged as
// unknown attributes.
const xml = `
<AssetDeclaration>
<GameObject id="GuardianTank">
<Draws>
<xi:include
href="DATA:Includes/HeadlightDraw2.xml"
xpointer="xmlns(n=uri:ea.com:eala:asset) xpointer(/n:HeadlightDraw2/child::*)" />
</Draws>
</GameObject>
</AssetDeclaration>`;
const doc = parseXml(xml);
const inc = doc.elements.find((e) => e.name === "xi:include");
assert.ok(inc);
assert.equal(model.isXsdElementName(inc.name), false);
assert.equal(resolveElementType(inc), null);
// The XInclude attributes themselves are unprefixed (model-valid name
// shape); the element-level foreign check is what keeps them quiet.
for (const a of inc.attrs) {
assert.equal(model.isXsdAttributeName(a.name), true, a.name);
}
});
+17
View File
@@ -53,6 +53,23 @@ test("Include has reference/instance/all enum", () => {
assert.deepEqual(type?.enumValues, ["reference", "instance", "all"]);
});
test("foreign namespaces are excluded from XSD validation", () => {
// XInclude elements (xi:include / xi:fallback) come from the W3C XInclude
// namespace, not from the EA asset XSD.
assert.equal(model.isXsdElementName("xi:include"), false);
assert.equal(model.isXsdElementName("xi:fallback"), false);
assert.equal(model.isXsdElementName("GameObject"), true);
assert.equal(model.isXsdElementName("AssetDeclaration"), true);
// EA schema attributes are unprefixed; prefixed attributes (xai:, xi:,
// xlink:, xml:, xsi:, xmlns:*) are namespace machinery.
assert.equal(model.isXsdAttributeName("href"), true);
assert.equal(model.isXsdAttributeName("xpointer"), true);
assert.equal(model.isXsdAttributeName("xai:joinAction"), false);
assert.equal(model.isXsdAttributeName("xlink:href"), false);
assert.equal(model.isXsdAttributeName("xml:space"), false);
assert.equal(model.isXsdAttributeName("xmlns:xi"), false);
});
test("type assignability follows inheritance", () => {
assert.ok(model.isAssignableTo("GameObject", "BaseInheritableAsset"));
assert.ok(model.isAssignableTo("GameObject", "GameObject"));