Hi Alexei,
Xalan "never" writes a null byte to the end of the stream, as it has no
idea that you're writing to a "string". This behavior has been consistent
since the first version of Xalan was released.
If this worked before it was just by chance, or was, as you suggested,
attributable to a particular library's behavior.
Dave
Alexei Dets
<[EMAIL PROTECTED]> To:
<[email protected]>
cc: (bcc: David N
Bertoni/Cambridge/IBM)
12/03/2002 03:09 Subject: Re: Xalan-1.4 crash
PM
Hi!
Seems that I've found the reason of the problem and it looks like a bug in
my
own code ;-)))
The bad thing is that this code compiles and works without any problems
with
the previous versions of Xalan, gcc-2.96 or Sun Workshop 6.0.
Probably the bug was triggered by update to gcc-3.2 or Xalan-1.4.
Here is the code example:
....
std::ostringstream resultStream;
XSLTResultTarget result(resultStream);
transformer.transform(*parsedXML, bodyXSL, result);
bodyStr = resultStream.str().c_str();
resultStream.seekp(0);
transformer.transform(*parsedXML, dateXSL, result);
dateStr = resultStream.str().c_str();
....
Seems that in the old setup calling "resultStream.seekp(0);" was cleaning
the
stream and setting write position to zero (or Xalan was writing '\0' to the
stream at the end of the transformation result), not it is only setting
position. So, in my case, result of the first transformation will be
correct,
of the second (and all subsequent) will contain trailing garbage from the
first transformation.
To achieve the same behaviour as before I've changed:
resultStream.seekp(0);
to:
resultStream.seekp(0);
resultStream.str("");
In this case it works as expected.
Alexei