|
@@ -1,3 +1,4 @@
|
|
|
+const Saxophone = require('saxophone');
|
|
|
const file = require('../file');
|
|
|
|
|
|
const ROOT_TAG = 'dblp';
|
|
@@ -24,10 +25,10 @@ const parser = class Parser {
|
|
|
this.callback = null;
|
|
|
this.source = null;
|
|
|
this.dest = null;
|
|
|
- this.sax = require('sax').createStream(true);
|
|
|
+ this.sax = new Saxophone();
|
|
|
this.sax.on('error', this._error);
|
|
|
- this.sax.on('opentag', this._opentag);
|
|
|
- this.sax.on('closetag', this._closetag);
|
|
|
+ this.sax.on('tagopen', this._opentag);
|
|
|
+ this.sax.on('tagclose', this._closetag);
|
|
|
this.sax.on('text', this._text);
|
|
|
}
|
|
|
|
|
@@ -47,7 +48,7 @@ const parser = class Parser {
|
|
|
}
|
|
|
}
|
|
|
this.callback = callback;
|
|
|
- file.fs.createReadStream(this.source).pipe(this.sax);
|
|
|
+ file.fs.createReadStream(this.source, {start: 77}).pipe(this.sax);
|
|
|
}
|
|
|
|
|
|
from(source) {
|
|
@@ -84,6 +85,7 @@ const parser = class Parser {
|
|
|
}
|
|
|
|
|
|
_closetag(tag) {
|
|
|
+ tag = tag.name;
|
|
|
if (tag === ROOT_TAG && instance.callback !== null) {
|
|
|
instance.callback(instance.dest);
|
|
|
} else if (instance._inTag && instance._tag === tag) {
|
|
@@ -99,7 +101,7 @@ const parser = class Parser {
|
|
|
|
|
|
_text(text) {
|
|
|
if (instance._isAuth) {
|
|
|
- instance._auth.push(text);
|
|
|
+ instance._auth.push(text.contents);
|
|
|
}
|
|
|
}
|
|
|
|