typesxml
Version:
Open source XML library written in TypeScript
71 lines • 2.2 kB
JavaScript
"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.XMLDocumentType = void 0;
const Constants_1 = require("./Constants");
class XMLDocumentType {
name;
systemId;
publicId;
internalSubset;
constructor(name, publicId, systemId) {
this.name = name;
this.publicId = publicId;
this.systemId = systemId;
}
setSystemId(systemId) {
this.systemId = systemId;
}
getSystemId() {
return this.systemId;
}
setPublicId(publicId) {
this.publicId = publicId;
}
getPublicId() {
return this.publicId;
}
setInternalSubset(subset) {
this.internalSubset = subset;
}
getInternalSubset() {
return this.internalSubset;
}
getNodeType() {
return Constants_1.Constants.DOCUMENT_TYPE_NODE;
}
toString() {
let doctype = '<!DOCTYPE ' + this.name;
if (this.publicId && this.systemId) {
doctype += ' PUBLIC "' + this.publicId + '" "' + this.systemId + '"';
}
else if (this.systemId) {
doctype += ' SYSTEM "' + this.systemId + '"';
}
else if (this.publicId) {
doctype += ' PUBLIC "' + this.publicId + '"';
}
if (this.internalSubset) {
doctype += ' [' + this.internalSubset.toString() + ']';
}
return doctype + '>';
}
equals(node) {
if (node instanceof DocumentType) {
return this.publicId === node.publicId && this.systemId === node.systemId;
}
return false;
}
}
exports.XMLDocumentType = XMLDocumentType;
//# sourceMappingURL=XMLDocumentType.js.map