mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-05-03 03:33:58 +00:00
improved xml importer
This commit is contained in:
@@ -31,7 +31,7 @@
|
|||||||
"prepublishOnly": "yarn build"
|
"prepublishOnly": "yarn build"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"node-xml-stream": "^1.0.2",
|
"node-xml-stream-parser": "^1.0.12",
|
||||||
"dbgate-plugin-tools": "^1.0.7",
|
"dbgate-plugin-tools": "^1.0.7",
|
||||||
"webpack": "^4.42.0",
|
"webpack": "^4.42.0",
|
||||||
"webpack-cli": "^3.3.11"
|
"webpack-cli": "^3.3.11"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const stream = require('stream');
|
const stream = require('stream');
|
||||||
const NodeXmlStream = require('node-xml-stream');
|
const NodeXmlStream = require('node-xml-stream-parser');
|
||||||
|
|
||||||
class ParseStream extends stream.Transform {
|
class ParseStream extends stream.Transform {
|
||||||
constructor({ itemElementName }) {
|
constructor({ itemElementName }) {
|
||||||
@@ -26,6 +26,17 @@ class ParseStream extends stream.Transform {
|
|||||||
if (this.stack.length >= 2) {
|
if (this.stack.length >= 2) {
|
||||||
this.stack[this.stack.length - 2].nodes[this.stack[this.stack.length - 1].name] = text;
|
this.stack[this.stack.length - 2].nodes[this.stack[this.stack.length - 1].name] = text;
|
||||||
}
|
}
|
||||||
|
if (this.stack.length >= 1) {
|
||||||
|
this.stack[this.stack.length - 1].nodes.$text = text;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.parser.on('cdata', (text) => {
|
||||||
|
if (this.stack.length >= 2) {
|
||||||
|
this.stack[this.stack.length - 2].nodes[this.stack[this.stack.length - 1].name] = text;
|
||||||
|
}
|
||||||
|
if (this.stack.length >= 1) {
|
||||||
|
this.stack[this.stack.length - 1].nodes.$text = text;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
this.parser.on('closetag', (name, attrs) => {
|
this.parser.on('closetag', (name, attrs) => {
|
||||||
if (name == element) {
|
if (name == element) {
|
||||||
|
|||||||
@@ -7607,10 +7607,10 @@ node-ssh-forward@^0.7.2:
|
|||||||
debug "^4.1.1"
|
debug "^4.1.1"
|
||||||
ssh2 "^0.8.9"
|
ssh2 "^0.8.9"
|
||||||
|
|
||||||
node-xml-stream@^1.0.2:
|
node-xml-stream-parser@^1.0.12:
|
||||||
version "1.0.2"
|
version "1.0.12"
|
||||||
resolved "https://registry.yarnpkg.com/node-xml-stream/-/node-xml-stream-1.0.2.tgz#7aa510f39ab125cc420e60a302f49147e80b000f"
|
resolved "https://registry.yarnpkg.com/node-xml-stream-parser/-/node-xml-stream-parser-1.0.12.tgz#2d97cc91147bbcdffa0a89cf7dfcc129db2aa789"
|
||||||
integrity sha512-W4LzsKQ1x3TldQQmXZfM/JO+3SPp+zzvA2Nf82chE7vXnZy7LqHjIqQe9yDUw58g2fTOaJo+DlPnIDfmozgsuw==
|
integrity sha512-qfUiDv1F6OMSltv2/ay32q7fp995OrA3TmEdlwFcxEjAQPiEAH+qi3jAh0QjOTXNbdLa5hoYhuBPCiylllGfjg==
|
||||||
|
|
||||||
nodemon@^2.0.2:
|
nodemon@^2.0.2:
|
||||||
version "2.0.2"
|
version "2.0.2"
|
||||||
|
|||||||
Reference in New Issue
Block a user