Casting to XMLCell or XMLBlobCell

Hi,

I am using the Structured Data --> XML --> XML Reader to import some XML into KNIME columns. In another node, I wish to read that XML and something funny happens:

This line...

XMLCell xmlcell = (XMLCell) row.getCell(1);

...yields this ERROR: Execute failed: org.knime.core.data.xml.XMLBlobCell cannot be cast to org.knime.core.data.xml.XMLCell

 

Ok let's change the casting.

XMLBlobCell xmlcell = (XMLBlobCell) row.getCell(1);

But...: Execute failed: org.knime.core.data.xml.XMLCell cannot be cast to org.knime.core.data.xml.XMLBlobCell

 

What is going on? Can't cast to either and both are telling me it's the other one? Maybe I am missing something obvious here, but any pointers would be greatly appreciated.

Thanks,

Rowi

Further investigation revealed that the XML Reader appears to deliver both CellTypes.

INFO  Node      0:13       processing row
INFO  Node      0:13       org.knime.core.data.xml.XMLBlobCell
INFO  Node      0:13       processing row
INFO  Node      0:13       org.knime.core.data.xml.XMLBlobCell
INFO  Node      0:13       processing row
INFO  Node      0:13       org.knime.core.data.xml.XMLCell
INFO  Node      0:13       processing row
INFO  Node      0:13       org.knime.core.data.xml.XMLBlobCell
INFO  Node      0:13       processing row
INFO  Node      0:13       org.knime.core.data.xml.XMLBlobCell
INFO  Node      0:13       processing row
INFO  Node      0:13       org.knime.core.data.xml.XMLBlobCell
INFO  Node      0:13       processing row
INFO  Node      0:13       org.knime.core.data.xml.XMLBlobCell
INFO  Node      0:13       processing row
INFO  Node      0:13       org.knime.core.data.xml.XMLCell
 

I am surprised at this type mixing in one column. Looking at the XML, it all looks the same. Well, for now I just

row.getCell(columnIndex).getType().getCellClass().getName();

and process accordingly...

Regards,

Rowi

You should cast to org.knime.core.data.xml.XMLValue.

Hi aborg,

Thanks for taking the time to reply. I had further described what I did in a comment that still seems to be in the queue for moderation. It is working either way. Still baffling though that apparently identical XML should produce different DataTypes in the same column.

Regards,

Rowi

The data type is the same, but the cell implementation is different, depending on the size. Therefore never ever cast to a cell implementation, only to the corresponding data value interface.

Thanks for explaining why this is happening!