Hi,
sorry for the late reaction,
here I send a minimalistic example of the malfunction:
- Code: Select all
| parserA parserB xmlStrA xmlStrB xmlDocA xmlDocB nodeC nodeW imp |
self halt.
parserA := AbtXmlDOMParser newNonValidatingParser.
parserB := AbtXmlDOMParser newNonValidatingParser.
xmlStrA := '<?xml version="1.0"?><a><b><c>ccc</c><d>ccc</d><e>eee</e></b></a>'.
xmlStrB := '<?xml version="1.0"?><v><w><x>ccc</x><y>ccc</y><z>eee</z></w></v>'.
[ xmlDocA := parserA parse: xmlStrA ] when: SgmlExceptions::SgmlException do: [].
[ xmlDocB := parserB parse: xmlStrB ] when: SgmlExceptions::SgmlException do: [].
nodeC := (xmlDocA getElementsByTagName: 'c') first.
nodeW := (xmlDocB getElementsByTagName: 'w') first.
imp := xmlDocA importNode: nodeW deep: true.
nodeC appendChild: imp.
self halt.
Calling the method >>appendChild invokes an error stating that the ownerDocuments are not the same and so it cannot proceed. In my opinion, the method >>importNode should make sure this error is not invoked.
I found that if I put the following two lines of code before calling >>appendChild, it works fine:
- Code: Select all
imp elementOwnerDocument: xmlDocA.
imp parent: nil.
The documentation for the >>importNode:deep: method says the following:
Imports a node from another document to this document. The returned node has no parent (parentNode is null). The source node is not altered or removed from the original document; this method creates a new copy of the source node.
What do you think about this?
Thank you!