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=14947>.
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=14947

DOMWriter don't interpret Entity Reference correctly

           Summary: DOMWriter don't interpret Entity Reference correctly
           Product: Xerces-C++
           Version: 2.1.0
          Platform: PC
        OS/Version: Windows NT/2K
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: DOM
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


We got an unexpected result in writing out DOM tree with DOMWriter.
 DOMWriter didn't understand defined Entity &amp and &lt and &quot.

 detail information is here :
 
 XML4C version : 5.0.0 ( XercesC++ 2.0.1 )
 Platform : PC
 OS : Windows2000/XP  
 Compiler : Microsoft VisualC++ 6.0 SP5
 XML Document : <root><text>&quot;AAAAA&quot; &amp; &lt;BBBBBB&gt; &amp; 
&apos;C&apos;</text></root>
 Output from DOMWriter : <root><text>"AAAAA" &amp; &lt;BBBBBB> 
&amp; 'C'</text></root>
 The C++ application code is attached below.
 We use 32bit binary package for Windows NT4.0 SP5/2000 using MSVC6.0 SP3

 What happend :
 
 When we write out DOM tree with DOMWriter, Entity Reference is not 
interpreted correctly. (see above output)
 We got this result when using DOMWriter method "writeToString" 
and "writeNode".
 also, We got similar result in writing attribute with DOMWriter.

   XML Document : <root><text attr=\"&quot;AAAAA&quot;  &amp; &lt;BBBBBB&gt; 
&amp; &apos;C&apos;\"/></root>
   Output from DOMWriter : <root><text attr="&quot;AAAAA&quot;  &amp; 
&lt;BBBBBB> &amp; 'C'"/></root>

 In this case, &quot ( which is interpreted appropriately in the case of 
text ) is not interpreted correctly.

 Is that usual ?


 [C++ applicaton code]

#include <string>
using namespace std;
#include <iostream>

#include <xercesc/util/PlatformUtils.hpp>
#include <xercesc/parsers/XercesDOMParser.hpp>
#include <xercesc/framework/MemBufInputSource.hpp>
#include <xercesc/dom/DOM.hpp>

//char* inputStr = "<root><text>&quot;AAAAA&quot; &amp; &lt;BBBBBB&gt; &amp; 
&apos;C&apos;</text></root>";
char* inputStr = "<root><text attr=\"&quot;AAAAA&quot;  &amp; &lt;BBBBBB&gt; 
&amp; &apos;C&apos;\"/></root>";

int
main(int argc, char* argv[])
{
        XMLCh   tmpStr[100];

        try {
                XMLPlatformUtils::Initialize();

                cout << "input xml string : " << endl;
                cout << inputStr << endl;

                XercesDOMParser* parser = new XercesDOMParser();
                MemBufInputSource* memBufIS = new MemBufInputSource((const 
XMLByte*)inputStr, strlen(inputStr), "test");
                parser->parse(*memBufIS);

                DOMDocument* doc = parser->getDocument();
                DOMNode* root = doc->getDocumentElement();

                XMLString::transcode("LS", tmpStr, 99);
                DOMImplementation* impl =  
DOMImplementationRegistry::getDOMImplementation(tmpStr);
                DOMWriter*      writer = ((DOMImplementationLS*)impl)-
>createDOMWriter();

                XMLCh* xstring = writer->writeToString(*root);

                char* outputStr = XMLString::transcode(xstring);
                cout << "output xmlstring : " << endl;
                cout << outputStr << endl;
                delete outputStr;

                writer->release();
                delete parser;
                delete memBufIS;

                XMLPlatformUtils::Terminate();
        }
        catch (const XMLException& e) {
                char* msg = XMLString::transcode(e.getMessage());
                cout << msg << endl;
                delete msg;
                return 1;
        }
        catch (exception e) {
                cout << e.what() << endl;
                return 1;
        }
        return 0;
}

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

Reply via email to