1 |
|
2 | var fs = require("fs"),
|
3 | util = require('util'),
|
4 | path = require("path"),
|
5 | xml = fs.cat(path.join(__dirname, "test.xml")),
|
6 | sax = require("../lib/sax"),
|
7 | strict = sax.parser(true),
|
8 | loose = sax.parser(false, {trim:true}),
|
9 | inspector = function (ev) { return function (data) {
|
10 | // util.error("");
|
11 | // util.error(ev+": "+util.inspect(data));
|
12 | // for (var i in data) util.error(i+ " "+util.inspect(data[i]));
|
13 | // util.error(this.line+":"+this.column);
|
14 | }};
|
15 |
|
16 | xml.addCallback(function (xml) {
|
17 | // strict.write(xml);
|
18 |
|
19 | sax.EVENTS.forEach(function (ev) {
|
20 | loose["on"+ev] = inspector(ev);
|
21 | });
|
22 | loose.onend = function () {
|
23 | // util.error("end");
|
24 | // util.error(util.inspect(loose));
|
25 | };
|
26 |
|
27 | // do this one char at a time to verify that it works.
|
28 | // (function () {
|
29 | // if (xml) {
|
30 | // loose.write(xml.substr(0,1000));
|
31 | // xml = xml.substr(1000);
|
32 | // process.nextTick(arguments.callee);
|
33 | // } else loose.close();
|
34 | // })();
|
35 |
|
36 | for (var i = 0; i < 1000; i ++) {
|
37 | loose.write(xml);
|
38 | loose.close();
|
39 | }
|
40 |
|
41 | });
|