|
From: Egon W. <e.w...@sc...> - 2006-03-07 12:53:07
|
On Tuesday 07 March 2006 12:31, peter murray-rust wrote: > At 09:26 07/03/2006, Egon Willighagen wrote: > > But after that transition back to 5.0, I still had that > >ClassCastException in this piece of code: > > > >CMLBuilder builder = new CMLBuilder(); > >CMLElement cmlElement = null; > >// cmlElement = (CMLElement) builder.build(file).getRootElement(); > >cmlElement = (CMLElement)builder.parseString(localResourceString); > > > >The cast to a CMLElement is failing. This caused trouble for me and for > >Tobias, with both Jumbo 5.1 and 5.0... Peter, ideas? > > This only works if the rootElement is a NAMESPACED CMLElement, else > it produces a simple Element. My guess is that you need to change the > namespace. I'm quite positive that this indeed is the problem. For some reason the namespace of the XOM Node was not set, while it did use "cml" prefix. I can imagine this to be the case for Tobias as well, because Bioclipse actually interprets CML at the Resource level, and splits up a CML file with a <molecule> and a <spectrum> on the same level into two childs below the CMLReource... and I can very well imagine that in this case too, XOM does not set the namespace for these Element's specifically, if set at a parent Node. :( > Namespaces are a problem since we haven't been very consistent in > CML. The current suggestion is that we always use > "http://www.xml-cml.org/schema". What we could then do is strip off > all other old CML namespaces at start of parse and replace by this one. Yes, stripping might be a good idea. At least they have the above in common. Egon -- e.w...@sc... PhD student on Molecular Representation in Chemometrics Radboud University Nijmegen Blog: http://chem-bla-ics.blogspot.com/ http://www.cac.science.ru.nl/people/egonw/ GPG: 1024D/D6336BA6 |