DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=13447>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=13447

DOMWriter doesn't work correctly

           Summary: DOMWriter doesn't work correctly
           Product: Xerces-C++
           Version: 2.1.0
          Platform: Other
        OS/Version: Windows NT/2K
            Status: NEW
          Severity: Major
          Priority: Other
         Component: DOM
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


I encountered some problems using the DOMWriter:

1) Layout output XML file
When I set the 'FormatPrettyPrint' feature and set the 'NewLine' to "\r\n", I 
expect to get a properly layout of XML. But the output is 'one' line with the 
XML.

2) Very slow in writing
I'am trying to construct a XML structure with the DOM and write this to a file. 
The constructing of the XML structure takes no more then a few seconds. The 
writing to the file (LocalFileFormatTarget) takes more then 2 minutes for a 
file of +/- 100k !? I tryed a workaround by using the MemBufFormatTarget and 
writing the buffer to a file. This is a lot faster (takes a few seconds), but 
this can't be done with UNICODE strings(?).

3) Can't write UNICODE (UTF-8)
I want to write the XML to a file in Unicode with UTF-8 encoding. I can open a 
XML file with UTF-8 encoding correctly. But when I write it to a file it is 
always ANSI and not Unicode.

I use Xerces-C++ in combination with VC++ 6.0 on a Windows 2000 machine.

code sample:

try
        {
                // get a serializer, an instance of DOMWriter
                XMLCh tempStr[100];
                XMLString::transcode("LS", tempStr, 99);
                DOMImplementation *impl          = 
DOMImplementationRegistry::getDOMImplementation(tempStr);
                DOMWriter         *theSerializer = ((DOMImplementationLS*)impl)-
>createDOMWriter();

                // set user specified end of line sequence and output encoding
                theSerializer->setNewLine( X("\r\n") );

                // plug in user's own error handler
                DOMErrorHandler *myErrorHandler = new CXmlErrorHandler();
                theSerializer->setErrorHandler(myErrorHandler);

                // set feature if the serializer supports the feature/mode
                bool gFormatPrettyPrint = true;
                if (theSerializer->canSetFeature
(XMLUni::fgDOMWRTFormatPrettyPrint, gFormatPrettyPrint))
                        theSerializer->setFeature
(XMLUni::fgDOMWRTFormatPrettyPrint, gFormatPrettyPrint);
                
                //
                // Plug in a format target to receive the resultant
                // XML stream from the serializer.
                //
                // StdOutFormatTarget prints the resultant XML stream
                // to stdout once it receives any thing from the serializer.
                //
                MemBufFormatTarget *myTarget = new MemBufFormatTarget();
                        //new LocalFileFormatTarget( strFilename );
                        //new StdOutFormatTarget();

                //
                // do the serialization through DOMWriter::writeNode();
                //
                theSerializer->writeNode(myTarget, *m_pDocument);
                
                ofstream lFile(strFilename);
                lFile << myTarget->getRawBuffer() << endl;
                
                delete theSerializer;

                //
                // Filter, formatTarget and error handler
                // are NOT owned by the serializer.
                //
                delete myTarget;

                bRetval = !((CXmlErrorHandler*)myErrorHandler)->getSawErrors();
                delete myErrorHandler;

                //if (gUseFilter)
                //      delete myFilter;        

        }
        catch (XMLException& e)
        {
                cerr << "An error occurred during creation of output 
transcoder. Msg is:"
                        << endl
                        << StrX(e.getMessage()) << endl;
                bRetval = false;
        }

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to