UNPKG

typesxml

Version:

Open source XML library written in TypeScript

46 lines 1.5 kB
/******************************************************************************* * 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 *******************************************************************************/ import { XMLUtils } from '../XMLUtils.js'; export 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.isValidXMLName(this.name); } toBNF() { return this.name + (this.cardinality ? this.cardinality : ''); } } //# sourceMappingURL=DTDElementNameParticle.js.map