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

it is not possible to parse a file and edit it after

           Summary: it is not possible to parse a file and edit it after
           Product: Xerces-C++
           Version: 2.3.0
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Non-Validating Parser
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


Hi,

I get the following problem with xercesc which seems to be a bug: it is not 
possible to parse a file and edit it after (I believe that it is a bug but I 
must confess that my knowledge of xerces is not realy good).

Xercesc version number: 2.3.0 which I build myself (using gcc following 
exactly the instructions command line of your web page).
Platform: Linux
Operating system: RedHat 9

Compiler: version gcc 3.2.2 20030222 (Red Hat Linux 3.2.2-5)

XML Document that failed:

<?xml version="1.0" encoding="UTF-8" standalone="no" ?><!DOCTYPE PollQ 
SYSTEM "PollQ.dtd"><PollQ><Question 
Comment="FALSE"><QData>TEST</QData><Answer>TEST</Answer></Question></PollQ>

DTD "PollQ.dtd":

<!ELEMENT PollQ (Question)+>
<!ELEMENT Question (QData, Answers*)>
<!ELEMENT QData (#PCDATA)>
<!ELEMENT Answer (#PCDATA)>
<!ATTLIST Question Comment (TRUE|FALSE) #REQUIRED>

C++ Code that failed:

That's the constructor of a window (using wxWindow lib)

PollFrame::PollFrame(const wxChar *title, const wxString path, int xpos, int 
ypos, int width, int height)
        :wxFrame((wxFrame *) NULL, -1, title, wxPoint(xpos,ypos), wxSize
(width, height)),
                PollPath(path), MenuBar(new wxMenuBar()), FileMenu(new wxMenu
()), 
                EditMenu(new wxMenu()), data(new wxTextCtrl(this, -1, wxString
(""), wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE | wxTE_READONLY)),
                nq(0U), na(0U), tmp1(new XMLCh[100]), tmp2(new XMLCh[100])
{
        // ...

        // Some wxWindows init (not needed) like menu etc...

        // ....

        // Start the data analysis
        
        XERCES_CPP_NAMESPACE::XMLPlatformUtils::Initialize();

        // the parser
        XERCES_CPP_NAMESPACE::XMLString::transcode("LS", tmp1, 99);
        impl=XERCES_CPP_NAMESPACE::DOMImplementationRegistry::getDOMImplementat
ion(tmp1);
        p = impl->createDOMBuilder
(XERCES_CPP_NAMESPACE::DOMImplementationLS::MODE_SYNCHRONOUS, 0);
        XERCES_CPP_NAMESPACE::XMLString::transcode("entities", tmp1, 99);
        p->setFeature(tmp1, false);

        // the serializer
        Serializer=impl->createDOMWriter();
        XERCES_CPP_NAMESPACE::XMLString::transcode("\n", tmp1, 99);
        Serializer->setNewLine(tmp1);

        if(path.IsEmpty()) // if new xml file (NO PROBLEM)
        {
                XERCES_CPP_NAMESPACE::XMLString::transcode("PollQ", tmp1, 99);
                XERCES_CPP_NAMESPACE::XMLString::transcode("PollQ.dtd", tmp2, 
99);
                Doctype=impl->createDocumentType(tmp1, NULL, tmp2);
                Doc=impl->createDocument(NULL, tmp1, Doctype);
                root=Doc->getDocumentElement();
        }
        else    // not new so whant to parse (PROBLEM)
        {
                Target= new XERCES_CPP_NAMESPACE::LocalFileFormatTarget
(static_cast<const char *>(PollPath));
                XERCES_CPP_NAMESPACE::XMLString::transcode(static_cast<const 
char *>(PollPath), tmp1, 99);
                try{
                        Doc=p->parseURI(tmp1);
                }
                catch(const XERCES_CPP_NAMESPACE::XMLException& e){
                        wxString m = XERCES_CPP_NAMESPACE::XMLString::transcode
(e.getMessage());
                        wxLogMessage("Exception: "+m+"\n");
                }
                catch(const XERCES_CPP_NAMESPACE::DOMException& e){
                        wxString m = XERCES_CPP_NAMESPACE::XMLString::transcode
(e.msg);
                        wxLogMessage("Exception: "+m+"\n");
                }
                catch(...){
                        wxLogMessage("Exception inconnu\n");
                }

                // no catch so should be OK

                Doctype=Doc->getDoctype();
                root=Doc->getDocumentElement();
        }
}

// when I whant to add an element then I call this function

void PollFrame::EditAddQ(wxCommandEvent &event)
{
        AddQDialog *Qdlg = new AddQDialog(this); // that's the dialog from 
witch I get data
        if(Qdlg->ShowModal() == wxID_OK)
        {
                // set question
                XERCES_CPP_NAMESPACE::XMLString::transcode("Question", tmp1, 
99);
                XERCES_CPP_NAMESPACE::DOMElement *q = Doc->createElement(tmp1);
                XERCES_CPP_NAMESPACE::XMLString::transcode("Comment", tmp1, 
99);
                if(Qdlg->IsCommentEnabled())
                {
                        XERCES_CPP_NAMESPACE::XMLString::transcode("TRUE", 
tmp2, 99);
                }else{
                        XERCES_CPP_NAMESPACE::XMLString::transcode("FALSE", 
tmp2, 99);
                }
                q->setAttribute(tmp1, tmp2);
                root->appendChild(q); // SEGFAULT HERE <-----------------------
--
                                        // when I whant to append child <------
--
                                        // and that it is an open file which <-
--
                                        // have been parse in the else <-------
--
                


                // the end don't seem to be a prob


                // set question data
                XERCES_CPP_NAMESPACE::XMLString::transcode("QData", tmp1, 99);
                XERCES_CPP_NAMESPACE::DOMElement *qd = Doc->createElement
(tmp1);
                XERCES_CPP_NAMESPACE::XMLString::transcode(static_cast<const 
char *>(Qdlg->GetQuestion()), tmp1, 99);
                XERCES_CPP_NAMESPACE::DOMText *qdt = Doc->createTextNode(tmp1);
                q->appendChild(qd);
                qd->appendChild(qdt);
                // set question answers
                int n = Qdlg->GetAnswersCount();
                if(static_cast<bool>(n))
                {
                        XERCES_CPP_NAMESPACE::DOMCDATASection *a;
                        for(int i=0U; i<n; ++i)
                        {
                                XERCES_CPP_NAMESPACE::XMLString::transcode
("Answer", tmp1, 99);
                                XERCES_CPP_NAMESPACE::DOMElement *a = Doc-
>createElement(tmp1);
                                XERCES_CPP_NAMESPACE::XMLString::transcode
(static_cast<const char *>(Qdlg->GetAnswersString(i)), tmp1, 99);
                                XERCES_CPP_NAMESPACE::DOMText *at = Doc-
>createTextNode(tmp1);
                                q->appendChild(a);
                                a->appendChild(at);
                        }
                }else{
                        XERCES_CPP_NAMESPACE::XMLString::transcode("Comment", 
tmp1, 99);
                        XERCES_CPP_NAMESPACE::XMLString::transcode("TRUE", 
tmp2, 99);
                        q->setAttribute(tmp1, tmp2);
                }
        }
        Qdlg->Destroy();
}

The following problem is:
If I create a new file it's OK (the if of the constructor is used).
If I parse a file (then the else of the constructor is used) and whant to edit 
after I get a segment fault (and crash at the indicate point in the code).

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

Reply via email to