typesxml
Version:
Open source XML library written in TypeScript
49 lines • 1.45 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";
import { XMLUtils } from "./XMLUtils.js";
export class XMLAttribute {
name;
value;
constructor(name, value) {
this.name = name;
this.value = value;
}
getName() {
return this.name;
}
getValue() {
return this.value;
}
setValue(value) {
this.value = value;
}
getNamespace() {
if (this.name.indexOf(':') === -1) {
return '';
}
return this.name.substring(0, this.name.indexOf(':'));
}
getNodeType() {
return Constants.ATTRIBUTE_NODE;
}
toString() {
return this.name + '="' + XMLUtils.unquote(XMLUtils.cleanString(this.value)) + '"';
}
equals(node) {
if (node instanceof XMLAttribute) {
return this.name === node.name && this.value === node.value;
}
return false;
}
}
//# sourceMappingURL=XMLAttribute.js.map