mirror of
https://github.com/gnh1201/welsonjs.git
synced 2024-11-26 15:31:42 +00:00
Update xml.js
This commit is contained in:
parent
0ab224b987
commit
b3facdcaae
49
lib/xml.js
49
lib/xml.js
|
@ -3,12 +3,13 @@
|
|||
////////////////////////////////////////////////////////////////////////
|
||||
var FILE = require("lib/file");
|
||||
|
||||
var adTypeText = 2;
|
||||
var adTypeBinary = 1;
|
||||
|
||||
var StreamConvert = function(data) {
|
||||
this.data = data;
|
||||
|
||||
this.toBinary = function() {
|
||||
var adTypeText = 2;
|
||||
var adTypeBinary = 1;
|
||||
var BinaryStream = CreateObject("ADODB.Stream");
|
||||
BinaryStream.Type = adTypeText;
|
||||
BinaryStream.CharSet = "utf-8";
|
||||
|
@ -21,8 +22,6 @@ var StreamConvert = function(data) {
|
|||
};
|
||||
|
||||
this.toString = function() {
|
||||
var adTypeText = 2;
|
||||
var adTypeBinary = 1;
|
||||
var BinaryStream = CreateObject("ADODB.Stream");
|
||||
BinaryStream.Type = adTypeBinary;
|
||||
BinaryStream.Open();
|
||||
|
@ -32,7 +31,6 @@ var StreamConvert = function(data) {
|
|||
BinaryStream.CharSet = "utf-8";
|
||||
return BinaryStream.ReadText();
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
var XMLObject = function(dom) {
|
||||
|
@ -122,11 +120,7 @@ var XMLObject = function(dom) {
|
|||
var node = dom.createElement("XMLNode");
|
||||
|
||||
node.dataType = type;
|
||||
if (type.indexOf("bin.") == 0) {
|
||||
node.nodeTypedValue = (new StreamConvert(value)).toBinary();
|
||||
} else {
|
||||
node.nodeTypedValue = value;
|
||||
}
|
||||
node.nodeTypedValue = (new StreamConvert(value)).toBinary();
|
||||
|
||||
return node.text;
|
||||
} catch (e) {
|
||||
|
@ -140,27 +134,36 @@ var XMLObject = function(dom) {
|
|||
var node = dom.createElement("XMLNode");
|
||||
|
||||
node.dataType = type;
|
||||
if (type.indexOf("bin.") == 0) {
|
||||
node.text = (new StreamConvert(value)).toString();
|
||||
} else {
|
||||
node.text = value;
|
||||
}
|
||||
node.text = value;
|
||||
|
||||
return node.nodeTypedValue;
|
||||
return (new StreamConvert(node.nodeTypedValue)).toString();
|
||||
} catch (e) {
|
||||
console.error("XMLObject->decode():", e.message);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
exports.create = function() {
|
||||
return (new XMLObject());
|
||||
};
|
||||
function create() {
|
||||
return new XMLObject();
|
||||
}
|
||||
|
||||
exports.load = function(s) {
|
||||
return (new XMLObject()).load(s);
|
||||
};
|
||||
function load(s) {
|
||||
return create().load(s);
|
||||
}
|
||||
|
||||
exports.VERSIONINFO = "XML interface (xml.js) version 0.2";
|
||||
function encode(value, type) {
|
||||
return create().encode(value, type);
|
||||
}
|
||||
|
||||
function decode(value, type) {
|
||||
return create().decode(value, type);
|
||||
}
|
||||
|
||||
exports.create = create;
|
||||
exports.load = load;
|
||||
exports.encode = encode;
|
||||
exports.decode = decode;
|
||||
|
||||
exports.VERSIONINFO = "XML interface (xml.js) version 0.2.2";
|
||||
exports.global = global;
|
||||
exports.require = global.require;
|
||||
|
|
Loading…
Reference in New Issue
Block a user