OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Copy DOM_Node from one DOM_Document to another DOM_Document?



I'm using Apache Xerces-C V1.4.0.

I've got two DOM_Documents in memory, and I want to subtitute a DOM_Node
instance
in one DOM_Document for another.

	Doc1:
	-----
	<Mpeg7>
	  <AudioVisual>
		<CreationInformation>...oldChildern..</CreationInformation>  // oldChild
	  </AudioVisual>
	</Mpeg7>

	Doc2:
	-----
	<Foo>
		<CreationInformation>...newChildren...</CreationInformation> // newChild
	</Foo>

	Modified Doc1:
	--------------
	<Mpeg7>
	  <AudioVisual>
		<CreationInformation>...newChildren...</CreationInformation>  // oldChild
	  </AudioVisual>
	</Mpeg7>

However, I can't do this directly, i.e., the following code generates
DOMException::WRONG_DOCUMENT_ERR:

 	// Find parent in doc1
	DOM_Element audioVisualElem =
		mp7->findElementByName("AudioVisual", 0);

	// Find oldChild in doc1
	DOM_Element oldCreationInformationElem =
		mp7->findElementByName("CreationInformation", 0);

	// Find newChild in doc2
	DOM_Element newCreationInformationElem =
		mp7LabelObj->findElementByName("CreationInformation", 0);
	// So far so good...

	// Replace doc1/oldchild with doc2/newchild
	// EXCEPTION: WRONG_DOCUMENT_ERR
  	audioVisualElem.replaceChild(newCreationInformationElem,
					     oldCreationInformationElem);

This exception makes a lot of sense, i.e., that DOM_Node's belong
to their DOM_Document parent.  However, is there any way to do this?

/eric rehm
singingfish.com
a thomson multimedia company
rehm@singingfish.com
1.206.883.3013
1.206.354.3459 (cell)