AW: [xml] problems with multiline comments
- From: "Uwe Pachler" <uwe pachler neo-media at>
- To: "Geert Kloosterman" <geertk ai rug nl>, <xml gnome org>
- Subject: AW: [xml] problems with multiline comments
- Date: Fri, 9 Aug 2002 16:15:21 +0200
thanks for the help!
I tracked down the error to the in-memory parsing routine. The problem is
that parsing stops after
the first chunk for some reason - right somewhere in the comment. The buffer
that I'm using is 1024 bytes in size, and what happened with the comments
was that the blew up the file beyond the 1024 bytes limit. so the parser
only parses the first chunk, and after that doesn't parse further. I have to
investigate this further, but maybe you are familiar with in-memory parsing
and can take a look at the code (basically the example, a bit tweaked to
work with c++ istreams):
///// PARSE XML DOCUMENT
xmlDoc* doc = NULL;
if (!is.good())
return NULL;
const int bufferSize = 1024;
char buffer[bufferSize];
xmlParserCtxtPtr ctxt;
xmlKeepBlanksDefault(0);
is.read(buffer, bufferSize);
if (is.gcount() > 0)
{
ctxt = xmlCreatePushParserCtxt(NULL, NULL, buffer, is.gcount(), NULL);
xmlParserErrors result = XML_ERR_OK;
while (is.gcount() > 0)
{
result = (xmlParserErrors)xmlParseChunk(ctxt, buffer, is.gcount(), 0);
is.read(buffer, bufferSize);
}
result = (xmlParserErrors)xmlParseChunk(ctxt, buffer, 0, 1);
doc = ctxt->myDoc;
xmlFreeParserCtxt(ctxt);
}
cheers,
Uwe
-----Ursprungliche Nachricht-----
Von: Geert Kloosterman [mailto:geertk ai rug nl]
Gesendet: Freitag, 09. August 2002 16:01
An: Uwe Pachler
Betreff: Re: [xml] problems with multiline comments
"Uwe" == Uwe Pachler <uwe pachler neo-media at> writes:
> Hi there!
> has anyone had problems with multiline comments yet?
> the following fraction
> <prototypes>
> <!--
> MULITLINE
> COMMENT
> TEXT
> -->
> <actor name="bellydancer" />
> <actor name="sheep">
> <sound name="baa" sample="sheep_baa.wav" />
> </actor>
> </prototypes>
> does parse, but the tree generated from it does not contain any
> actor nodes. If I replace the comment with a single line
> comment ("<!-- comment -->") it works...
Hi Uwe,
I can't reproduce this.
Running "xmllint --debug" on your fragment does show the actor nodes
in the the output. This means the actor nodes do exist in the tree
generated by the parser.
I've also used lots of xslt files containing many multiline comments
with libxml/libxslt without any problems.
I'm using libxml version 2.4.23.
Geert
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]