UNPKG

typesxml

Version:

Open source XML library written in TypeScript

71 lines 2.33 kB
"use strict"; /******************************************************************************* * Copyright (c) 2023 - 2024 Maxprograms. * * This program and the accompanying materials * are made available under the terms of the Eclipse 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.XMLDeclaration = void 0; const Constants_1 = require("./Constants"); class XMLDeclaration { version; encoding; standalone; constructor(version, encoding, standalone) { if (version !== '' && !('1.0' === version || '1.1' === version)) { throw new Error('Incorrect XML version'); } this.version = version; this.encoding = encoding; if (standalone !== undefined) { if (!('yes' === standalone || 'no' === standalone)) { throw new Error('Incorrect "standalone" value'); } this.standalone = standalone; } } getVersion() { return this.version; } setVersion(version) { this.version = version; } getEncoding() { return this.encoding; } setEncoding(encoding) { this.encoding = encoding; } getStandalone() { return this.standalone; } setStandalone(standalone) { this.standalone = standalone; } getNodeType() { return Constants_1.Constants.XML_DECLARATION_NODE; } toString() { return '<?xml' + (this.version !== '' ? ' version="' + this.version + '"' : '') + (this.encoding !== '' ? ' encoding="' + this.encoding + '"' : '') + (this.standalone ? ' standalone="' + this.standalone + '"' : '') + '?>'; } equals(node) { if (node instanceof XMLDeclaration) { return this.version === node.version && this.encoding === node.encoding && this.standalone === node.standalone; } return false; } } exports.XMLDeclaration = XMLDeclaration; //# sourceMappingURL=XMLDeclaration.js.map