Preface: I'm working on docx parser for java. docx format is based on xml. When I read document its parts are being unmarshalled (with JAXB). And I get a tree of certain elements based on xml markup.
Almost problem: But some elements (which are at very deep xml level) returned not as certain class from docx spec (i.e. CTStyle, CTDrawing, CTInline etc) but as Object. Those objects are indeed instances of xerces classes, e.g. ElementNSImpl.
Problem: How should I handle objects from xerces (e.g. ElementNSImpl)? The simplest approach is:
CTGraphicData gData = getGraphicData ();
Object obj = gData.getAny().get(0);
ElementNSImpl element = (ElementNSImpl)obj;
But it doesn't seem to be a good solution. I've never worked with xerces directly. What is the better way to do this casting? (If anyone also give me a tip about right way to iterate through nodes it would be great).