/usr/lib/nodejs/ltx/sax_easysax.js is in node-ltx 0.2.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | var util = require('util');
var events = require('events');
var Easysax = require('easysax');
/**
* FIXME: This SAX parser cannot be pushed to!
*/
var SaxEasysax = module.exports = function SaxEasysax() {
events.EventEmitter.call(this);
this.parser = new Easysax();
var that = this;
this.parser.on('startNode', function(name, attr, uq, str, tagend) {
attr = attr();
for(var k in attr)
if (attr.hasOwnProperty(k)) {
attr[k] = uq(attr[k]);
}
that.emit('startElement', name, attr);
});
this.parser.on('endNode', function(name, uq, str, tagstart) {
that.emit('endElement', name);
});
this.parser.on('textNode', function(str, uq) {
that.emit('text', uq(str));
});
this.parser.on('cdata', function(str) {
that.emit('text', str);
});
this.parser.on('error', function(e) {
that.emit('error', e);
});
// TODO: other events, esp. entityDecl (billion laughs!)
};
util.inherits(SaxEasysax, events.EventEmitter);
SaxEasysax.prototype.write = function(data) {
if (typeof data !== 'string')
data = data.toString();
this.parser.parse(data);
};
SaxEasysax.prototype.end = function(data) {
if (data)
this.write(data);
};
|