AbtDOMDocument>>importNode: malfunction

VA Smalltalk is a "100% VisualAge compatible" IDE that includes the original VisualAge technology and the popular VA Assist and WidgetKit add-ons.

Moderators: Eric Clayberg, wembley, tc, Diane Engles, solveig

AbtDOMDocument>>importNode: malfunction

Postby MartinCz » Wed May 05, 2010 8:52 am

Hi.

I don't know if this is the right place to report a suspected bug, but:

The AbtDOMDocument>>importNode: method declares to do 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. "

It neither changes the parent nor the ownerDocument of the nodes. Is this problem known? Is there any workaround?

Thank you for any answers!
MartinCz
 
Posts: 7
Joined: Wed Mar 31, 2010 3:56 am

Re: AbtDOMDocument>>importNode: malfunction

Postby tc » Sat May 08, 2010 2:30 am

Hello,

Can you provide some code or context as to what you're trying to do?

Thanks.

--tc
tc
Moderator
 
Posts: 304
Joined: Tue Oct 17, 2006 7:40 am
Location: Raleigh, NC

Re: AbtDOMDocument>>importNode: malfunction

Postby MartinCz » Wed May 26, 2010 1:02 am

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!
MartinCz
 
Posts: 7
Joined: Wed Mar 31, 2010 3:56 am


Return to VA Smalltalk 7.0, 7.5 & 8.0

Who is online

Users browsing this forum: No registered users and 1 guest