Open magicmonkey opened 13 years ago
This happens with node-xml's example.js as well:
node v0.5.0-pre & node-xml v1.0.0 (via npm install)
// ...
cb.onStartDocument(function() {
sys.puts("DOC-START");
});
cb.onEndDocument(function() {
sys.puts("DOC-END");
});
// ...
//example read from chunks
parser.parseString("<html><body>");
parser.parseString("<!-- This is the start");
parser.parseString(" and the end of a comment -->");
parser.parseString("and lots");
parser.parseString("and lots of text&am");
parser.parseString("p;some more.");
parser.parseString("<![CD");
parser.parseString("ATA[ this is");
parser.parseString(" cdata ]]>");
parser.parseString("</body");
parser.parseString("></html>");
Outputs:
DOC-START
=> Started: html uri=null (Attributes: [] )
=> Started: body uri=null (Attributes: [] )
DOC-END
<COMMENT> This is the start and the end of a comment </COMMENT>
DOC-END
DOC-END
DOC-END
<CDATA> this is cdata </CDATA>
DOC-END
<= End: body uri=null
<= End: html uri=null
When parsing an entire file at once:
//example read from file
parser.parseFile("sample.xml");
onEndDocument()
isn't called at all.
When running this code: https://gist.github.com/900680 on an XML file with 76 <row ... /> elements in it (and some starting and ending tags), the onEndDocument callback gets called several times. Interestingly, it gets called more times if I reduce the size of the chunks (and therefore increase the number of chunks) being pushed through the parser, but it's not called as many times as the number of chunks.
For example, here is a run with chunkSize=100:
Here is a sample of mkttmpl.xml:
In my file, there are 76
tags, all between a single tag.