Uploaded image for project: 'Xerces-C++'
  1. Xerces-C++
  2. XERCESC-1973

problem while impoting node form one document and writing to the other document.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Not A Problem
    • 2.8.0
    • 2.8.0
    • DOM
    • SunOs, Linux

    Description

      I am trying to import node from one document and adding that node to the other document...

      corrupt_impl = DOMImplementationRegistry::getDOMImplementation(XML);
      if (corrupt_impl != NULL)

      { /* create the document */ corruptedDoc = corrupt_impl->createDocument( NULL, // root element namespace URI. inRoot->getNodeName(), // root element name NULL); // document type object (DTD). /* get the pointer to the root element */ corruptedRoot = corruptedDoc->getDocumentElement(); }

      Loop()
      {
      DOMNode* corrupted = List; /* getting the node from other document */
      corruptedRoot->appendChild(corruptedDoc->importNode(corrupted, true));
      }

      DOMErrorHandler WriterErrHandler = (DOMErrorHandler) new HandlerBase();
      corruptwriter->setErrorHandler(WriterErrHandler);

      /* set the features to the writer.*/
      if(corruptwriter->canSetFeature(XMLUni::fgDOMWRTFormatPrettyPrint, true))
      corruptwriter->setFeature(XMLUni::fgDOMWRTFormatPrettyPrint , true);

      /* write the entire document to the file */
      corruptwriter->writeNode(corruptfile , *corruptedDoc);

      corruptedDoc->release();

      if I run the code every time when the Loop() repeats new node is added to the root only but in the previous line like this.

      <?xml version="1.0" encoding="UTF-8" standalone="no" ?>
      <personnel>

      <person id="one.worker">
      <name>
      <family>Worker</family>
      <given>One</given>
      </name>
      <email>one@foo.com</email>
      </person><person id="three.worker">
      <name>
      <family>Worker</family>
      <given>One</given>
      </name>
      <email>one@foo.com</email>
      </person>
      </personnel>

      But I need the output as following. How can I achieve it..

      <?xml version="1.0" encoding="UTF-8" standalone="no" ?>
      <personnel>
      <person id="one.worker">
      <name>
      <family>Worker</family>
      <given>One</given>
      </name>
      <email>one@foo.com</email>
      </person>
      <person id="three.worker">
      <name>
      <family>Worker</family>
      <given>One</given>
      </name>
      <email>one@foo.com</email>
      </person>
      </personnel>

      Attachments

        Activity

          People

            Unassigned Unassigned
            dineshreddy Dinesh Reddy
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - 168h
                168h
                Remaining:
                Remaining Estimate - 168h
                168h
                Logged:
                Time Spent - Not Specified
                Not Specified