/usr/lib/nodejs/ltx/sax_saxjs.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 | var util = require('util');
var events = require('events');
var sax = require('sax');
var SaxSaxjs = module.exports = function SaxSaxjs() {
events.EventEmitter.call(this);
this.parser = sax.parser(true);
var that = this;
this.parser.onopentag = function(a) {
that.emit('startElement', a.name, a.attributes);
};
this.parser.onclosetag = function(name) {
that.emit('endElement', name);
};
this.parser.ontext = function(str) {
that.emit('text', str);
};
this.parser.onend = function() {
that.emit('end');
};
this.parser.onerror = function(e) {
that.emit('error', e);
};
// TODO: other events, esp. entityDecl (billion laughs!)
};
util.inherits(SaxSaxjs, events.EventEmitter);
SaxSaxjs.prototype.write = function(data) {
if (typeof data !== 'string')
data = data.toString();
this.parser.write(data);
};
SaxSaxjs.prototype.end = function(data) {
if (data)
this.parser.write(data);
this.parser.close();
};
|