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

                 Key: XERCESC-1973
                 URL: https://issues.apache.org/jira/browse/XERCESC-1973
             Project: Xerces-C++
          Issue Type: Bug
          Components: DOM
    Affects Versions: 2.8.0
         Environment: SunOs, Linux
            Reporter: Dinesh Reddy
             Fix For: 2.8.0


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(i);   /* 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>[email protected]</email>
  </person><person id="three.worker">
    <name>
      <family>Worker</family>
      <given>One</given>
    </name>
    <email>[email protected]</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>[email protected]</email>
  </person>
<person id="three.worker">
    <name>
      <family>Worker</family>
      <given>One</given>
    </name>
    <email>[email protected]</email>
  </person>
</personnel>


--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to