You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-dev@xmlgraphics.apache.org by Arek Stryjski <ar...@gmail.com> on 2005/09/09 10:49:27 UTC

Document.importNode() bug

Hi,

I think I found bug in SVN (05-09-02) version of Batik.

In one of my classes I call org.w3c.dom.Document.importNode(Node,
boolean); method to import nodes from Apache XmlBeans into Batik.
This is executed at run time by org.apache.batik.dom.AbstractDocument.
This class in importNode(Node, boolean, boolean) on line 393 calls:

fireUserDataHandlers(UserDataHandler.NODE_IMPORTED, importedNode, result);

This method is implemented in org.apache.batik.dom.AbstractNode on
line 884. Unfortunately this method assume imported Node came from
Batik, and on next line cast Node (in my case
org.apache.xmlbeans.impl.store.Xobj$AttrXobj) into
org.apache.batik.dom.AbstractNode. Of course this throws
ClassCastException.

I believe this this is bug and violation of API. It should be possible
to import Nodes from any system which implements W3C DOM into Batik.

I think in AbstractNode you should change method parameters into
fireUserDataHandlers(int, AbstractNode, AbstractNode), and check in
AbstractDocument if imported Node is instance of   AbstractNode, and
only if it is calling this method. However maybe you will came with
better solution for this problem, as you know Batik code much better.

Best regards
Arek

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-dev-help@xmlgraphics.apache.org


Re: Document.importNode() bug

Posted by Cameron McCormack <ca...@aka.mcc.id.au>.
Arek Stryjski:
> Thanks Cameron for quick answer. It will be really nice if you will
> find time soon.

This is fixed in SVN now.

-- 
  e-mail : cam (at) mcc.id.au    	icq : 26955922
     web : http://mcc.id.au/	        msn : cam-msn (at) aka.mcc.id.au
  office : +61399055779		     jabber : heycam (at) jabber.org

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-dev-help@xmlgraphics.apache.org


Re: Document.importNode() bug

Posted by Arek Stryjski <ar...@gmail.com>.
> Yes, I think you are right. 
> (...)
> I'll look into fixing this soon.
> 

Thanks Cameron for quick answer. It will be really nice if you will
find time soon.

Best regards
Arek

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-dev-help@xmlgraphics.apache.org


Re: Document.importNode() bug

Posted by Cameron McCormack <ca...@aka.mcc.id.au>.
Hi Arek.

Arek Stryjski:
> This method is implemented in org.apache.batik.dom.AbstractNode on
> line 884. Unfortunately this method assume imported Node came from
> Batik, and on next line cast Node (in my case
> org.apache.xmlbeans.impl.store.Xobj$AttrXobj) into
> org.apache.batik.dom.AbstractNode. Of course this throws
> ClassCastException.

Yes, I think you are right.  It would be nice if there were a good way
to call the UserDataHandlers if the other implementation supports DOM 3,
but I don't see how that would be possible.  I'll look into fixing this
soon.

Thanks,

Cameron

-- 
  e-mail : cam (at) mcc.id.au    	icq : 26955922
     web : http://mcc.id.au/	        msn : cam-msn (at) aka.mcc.id.au
  office : +61399055779		     jabber : heycam (at) jabber.org

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-dev-help@xmlgraphics.apache.org