Colin,
The data got flushed in LocalFileFormatTarget destructor. So I guess the
object "local_file" is not destroyed in your Eiffel program and thus
problem; while in C++ it is destroyed when going out of scope.
I think I should fix the code and move the method
"LocalFileFormatTarget::flushBuffer()" from private to public so that caller
can actively flush the buffer if needed.
In the meantime may be you can check why the "local_file" is not destroyed
in your Eiffel program.
Tinny
----- Original Message -----
From: "Colin Paul Adams" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, January 24, 2003 10:50 AM
Subject: Re: Bug 15928 not fixed in latest nightly builds
> >>>>> "Tinny" == Tinny Ng <[EMAIL PROTECTED]> writes:
>
> >> Would you like me to write the equivalent pure C++ program?
> Tinny> Yes please. Appreciated.
>
> Well, I've done so, and there is no difference between 2.1.0 and 11th
> January nightly build!
> Of course, the equivalent program is not IDENTICAL to my Eiffel
> implementation (as it consists of several layers of bridging), but it
> ought to be the same.
>
> Now I look at the source code for writeChars, and immediately noticed
> that there was no flushing of the data buffer there. When I look at
> 2.1.0 I instead see a call to writeBufferToFile.
>
> So I imagine that for some reason the buffers are getting flushed at
> some time with my C++ equivalent, but not in the case of the Eiffel
> bridging implementation.
>
> Can you suggest a line of attack for this problem please?
>
> First, here's the code of the C++ equivalent:
>
> #include <xercesc/dom/DOM.hpp>
> #include <xercesc/util/PlatformUtils.hpp>
> #include <xercesc/util/XMLString.hpp>
> #include <xercesc/framework/LocalFileFormatTarget.hpp>
>
> XERCES_CPP_NAMESPACE_USE
>
> main ()
> {
>
> XMLPlatformUtils::Initialize();
>
> DOMImplementation * impl =
DOMImplementationRegistry::getDOMImplementation ( XMLString::transcode (
"XML 1.0 Core 3.0 LS" ) );
>
> DOMDocument * document = impl->createDocument ( XMLString::transcode (
"urn:colina.demon.co.uk:domwriter-test-one" ), XMLString::transcode (
"test:document" ), 0 ) ;
>
> DOMElement * document_element = document->getDocumentElement ();
> document_element->setAttributeNS ( XMLString::transcode (
"http://www.w3.org/2000/xmlns/" ), XMLString::transcode ( "xmlns:test" ),
> XMLString::transcode (
"urn:colina.demon.co.uk:domwriter-test-one" ) );
>
> DOMElement * sub_element = document->createElement (
XMLString::transcode ( "doNotPrint" ) );
> document_element->appendChild ( sub_element );
>
> DOMProcessingInstruction * pi = document->createProcessingInstruction
( XMLString::transcode ( "target" ), XMLString::transcode ( "some target
data" ) );
> document->appendChild ( pi );
>
> DOMWriter * writer = static_cast<DOMImplementationLS *> (
impl )->createDOMWriter ();
> writer->setFeature( XMLString::transcode ( "format-pretty-print" ),
true );
>
> LocalFileFormatTarget local_file ( XMLString::transcode (
"/tmp/test.xml" ) );
>
> writer->writeNode ( &local_file, *document );
> writer->release ();
>
> XMLPlatformUtils::Terminate();
> }
>
> Now for the effective differences with the Eiffel implementation:
>
> 1) I have no call to release or Terminate (I have still to consider
> how best to do these automatically - as my Eiffel code is supposed to
> be pure DOM, with multiple possible implementations). But the above
> code works even if you comment these out.
> 2) Rather than calling XMLString::transcode, I create a UTF-8
> transcoder, and use that (as pure ascii is a subset of UTF-8).
>
> BTW the same code, if writing to StdOutFormatTarget, or
> MemBufFormatTarget, works.
>
> --
> Colin Paul Adams
> Preston Lancashire
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]