Update xml.js

This commit is contained in:
Namhyeon Go 2022-01-18 00:45:23 +09:00 committed by GitHub
parent f3628b9887
commit 3050a01ab9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -117,32 +117,44 @@ var XMLObject = function(dom) {
} }
this.encode = function(value, type) { this.encode = function(value, type) {
var dom = this.getDOM(); try {
var dom = this.getDOM();
dom.dataType = type; dom.dataType = type;
if (type.indexOf("bin.") == 0) { if (type.indexOf("bin.") == 0) {
dom.nodeTypedValue = (new StreamConvert(value)).toBinary(); dom.nodeTypedValue = (new StreamConvert(value)).toBinary();
} else { } else {
dom.nodeTypedValue = value; dom.nodeTypedValue = value;
}
return dom.text;
} catch (e) {
console.error("XMLObject->encode():", e.message);
} }
return dom.text;
}; };
this.decode = function(value, type) { this.decode = function(value, type) {
var dom = this.getDOM(); try {
var dom = this.getDOM();
dom.dataType = type; dom.dataType = type;
if (type.indexOf("bin.") == 0) { if (type.indexOf("bin.") == 0) {
dom.text = (new StreamConvert(value)).toString(); dom.text = (new StreamConvert(value)).toString();
} else { } else {
dom.text = value; dom.text = value;
}
return dom.nodeTypedValue;
} catch (e) {
console.error("XMLObject->decode():", e.message);
} }
return dom.nodeTypedValue;
}; };
}; };
exports.create = function() {
return (new XMLObject());
};
exports.load = function(s) { exports.load = function(s) {
return (new XMLObject()).load(s); return (new XMLObject()).load(s);
}; };