UNPKG

typesxml

Version:

Open source XML library written in TypeScript

100 lines 3.11 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.EntityDecl = void 0; const Constants_js_1 = require("../Constants.js"); class EntityDecl { name; parameterEntity; value; systemId; publicId; ndata; externalContentLoaded = false; // Track if external content has been loaded unresolvedExternalError = null; constructor(name, parameterEntity, value, systemId, publicId, ndata) { // parameterEntities are only used in DTDs this.name = name; this.parameterEntity = parameterEntity; this.value = value; this.systemId = systemId; this.publicId = publicId; this.ndata = ndata; } getName() { return this.name; } getValue() { return this.value; } setValue(value) { this.value = value; if (this.systemId || this.publicId) { this.externalContentLoaded = true; } this.unresolvedExternalError = null; } isExternalContentLoaded() { return this.externalContentLoaded; } markUnresolved(errorMessage) { this.unresolvedExternalError = errorMessage; } getUnresolvedError() { return this.unresolvedExternalError; } isParameterEntity() { return this.parameterEntity; } getSystemId() { return this.systemId; } getPublicId() { return this.publicId; } getNotationName() { return this.ndata; } isExternal() { return this.systemId !== '' || this.publicId !== ''; } getNodeType() { return Constants_js_1.Constants.ENTITY_DECL_NODE; } toString() { let result = '<!ENTITY ' + (this.parameterEntity ? '% ' : '') + this.name; if (this.publicId !== '' && this.systemId !== '') { result += ' PUBLIC "' + this.publicId + '" "' + this.systemId + '">'; } else if (this.systemId !== '') { result += ' SYSTEM "' + this.systemId + '">'; } else { result += ' "' + this.value + '">'; } return result; } equals(node) { if (node instanceof EntityDecl) { return this.name === node.name && this.parameterEntity === node.parameterEntity && this.value === node.value && this.systemId === node.systemId && this.publicId === node.publicId && this.ndata === node.ndata; } return false; } } exports.EntityDecl = EntityDecl; //# sourceMappingURL=EntityDecl.js.map