UNPKG

typesxml

Version:

Open source XML library written in TypeScript

50 lines 1.69 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.DTDElementNameParticle = void 0; const XMLUtils_js_1 = require("../XMLUtils.js"); class DTDElementNameParticle { name; cardinality = ''; constructor(name, cardinality) { this.name = name; if (cardinality) this.cardinality = cardinality; } getType() { return 'element'; } getName() { return this.name; } getCardinality() { return this.cardinality; } validate() { // Cardinality must be '', '*', '+', or '?' if (this.cardinality && !['*', '+', '?'].includes(this.cardinality)) { return false; } // #PCDATA is always valid for mixed content if (this.name === '#PCDATA') { return true; } // Name must be non-empty and valid NCName return !!this.name && XMLUtils_js_1.XMLUtils.isValidXMLName(this.name); } toBNF() { return this.name + (this.cardinality ? this.cardinality : ''); } } exports.DTDElementNameParticle = DTDElementNameParticle; //# sourceMappingURL=DTDElementNameParticle.js.map