You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by "Dinesh Reddy (Created) (JIRA)" <xe...@xml.apache.org> on 2011/10/28 08:42:32 UTC
[jira] [Created] (XERCESC-1973) problem while impoting node form
one document and writing to the other document.
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>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>
--
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: c-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: c-dev-help@xerces.apache.org
[jira] [Closed] (XERCESC-1973) problem while impoting node form one
document and writing to the other document.
Posted by "Alberto Massari (Closed) (JIRA)" <xe...@xml.apache.org>.
[ https://issues.apache.org/jira/browse/XERCESC-1973?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Alberto Massari closed XERCESC-1973.
------------------------------------
Resolution: Not A Problem
Please don't open bugs for asking questions; use the c-users@xerces.apache.org mailing list
> 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>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>
--
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: c-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: c-dev-help@xerces.apache.org
[jira] [Commented] (XERCESC-1973) problem while impoting node form
one document and writing to the other document.
Posted by "subins jose (JIRA)" <xe...@xml.apache.org>.
[ 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>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>
--
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: c-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: c-dev-help@xerces.apache.org