UNPKG

typesxml

Version:

Open source XML library written in TypeScript

52 lines 2.21 kB
"use strict"; /******************************************************************************* * Copyright (c) 2023-2026 Maxprograms. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 1.0 * which accompanies this distribution, and is available at * https://www.eclipse.org/org/documents/epl-v10.html * * Contributors: * Maxprograms - initial API and implementation *******************************************************************************/ Object.defineProperty(exports, "__esModule", { value: true }); exports.SchemaElementParticle = void 0; const SchemaParticle_js_1 = require("./SchemaParticle.js"); class SchemaElementParticle extends SchemaParticle_js_1.SchemaParticle { name; additionalNames; constructor(name, minOccurs = 1, maxOccurs = 1, additionalNames) { super(minOccurs, maxOccurs); this.name = name; this.additionalNames = additionalNames !== undefined ? additionalNames : new Set(); } matchOnce(children, pos, _nsMap, _childNamespaces) { if (pos >= children.length) { return []; } const childName = children[pos]; if (childName === this.name) { return [pos + 1]; } // Compare by local name, ignoring any namespace prefix on either side. const particleColon = this.name.indexOf(':'); const childColon = childName.indexOf(':'); const particleLocal = particleColon !== -1 ? this.name.substring(particleColon + 1) : this.name; const childLocal = childColon !== -1 ? childName.substring(childColon + 1) : childName; if (particleLocal === childLocal) { return [pos + 1]; } // Check substitution group members. for (const altName of this.additionalNames) { const altColon = altName.indexOf(':'); const altLocal = altColon !== -1 ? altName.substring(altColon + 1) : altName; if (childLocal === altLocal) { return [pos + 1]; } } return []; } } exports.SchemaElementParticle = SchemaElementParticle; //# sourceMappingURL=SchemaElementParticle.js.map