typesxml
Version:
Open source XML library written in TypeScript
70 lines • 2.24 kB
JavaScript
/*******************************************************************************
* Copyright (c) 2023-2026 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
*******************************************************************************/
import { Constants } from "./Constants.js";
export 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.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 XMLDocumentType) {
const samePublicId = this.publicId === node.publicId;
const sameSystemId = this.systemId === node.systemId;
const sameInternalSubset = this.internalSubset === node.internalSubset;
return samePublicId && sameSystemId && sameInternalSubset;
}
return false;
}
}
//# sourceMappingURL=XMLDocumentType.js.map