[
https://issues.apache.org/jira/browse/XERCESC-1973?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13503661#comment-13503661
]
subins jose commented on XERCESC-1973:
--------------------------------------
Hi,
I am new to xerces c++. I have also same problem. I have one node, that is
imported from second document. when I append this imported node to first
document, it throws an exception, "node is used in a different document than
the one that created it". I cannot find out any issue is there. I am using
xerces 3.1.1 version. Following is the my current implementation.
DOMImplementation* pDOMImplementation =
DOMImplementationRegistry::getDOMImplementation(XMLString::transcode( "CORE" ));
pDOMParser =
pDOMImplementation->createLSParser(DOMImplementationLS::MODE_SYNCHRONOUS, 0);
if( pDOMParser->getDomConfig()->canSetParameter( XMLUni::fgDOMValidate,
true ) )
pDOMParser->getDomConfig()->setParameter(
XMLUni::fgDOMValidate, true );
if( pDOMParser->getDomConfig()->canSetParameter(
XMLUni::fgDOMNamespaces, true ) )
pDOMParser->getDomConfig()->setParameter(
XMLUni::fgDOMNamespaces, true );
if( pDOMParser->getDomConfig()->canSetParameter(
XMLUni::fgDOMDatatypeNormalization, true ) )
pDOMParser->getDomConfig()->setParameter(
XMLUni::fgDOMDatatypeNormalization, true );
pFirstDOMDocumnt = pDOMParser->parseURI(path);
pSecondDOMDocumnt = pDOMParser->parseURI(path);
......
try
{
DOMNode* pImportedNode =pSecondDOMDocumnt->importNode(pChild, true);
pParent->appendChild(pChildElement);
}
catch(DOMException exe)
{
fprintf(stdout,"Exception : %S\n",exe.getMessage());
}
Can I do any mistake ?
Can you please help?
> 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
> Labels: xerces
> Fix For: 2.8.0
>
> Original Estimate: 168h
> Remaining Estimate: 168h
>
> 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
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]