Hi,
According to the API specification,
javax.xml.parse rs.DocumentBuil der.parse should return an
org.w3c.dom.Doc ument. However, when I use the following code:
DocumentBuilder Factory factory = DocumentBuilder Factory.newInst ance();
factory.setVali dating(false);
factory.setName spaceAware(fals e);
DocumentBuilder builder = factory.newDocu mentBuilder();
ByteArrayInputS tream xmlIs = new
ByteArrayInputS tream(polisLijs t.getBytes());
Object parseReturn = builder.parse(x mlIs);
System.out.prin tln("######## ["+parseReturn.g etClass().getNa me()+"]
######");
Document xmlDoc = (Document) parseReturn;
the println prints:
######## [org.apache.xerc es.dom.Deferred DocumentImpl] ######
and the final statement gives an exception:
[java.lang.Class CastException]
[org.apache.xerc es.dom.Deferred DocumentImpl]
stack-trace=[java.lang.Class CastException: ...
Why do I get an DeferredDocumen tImpl when I should get a Document? Am
I doing something wrong? Or else: how do I create a Document from this
mysterious DeferredDocumen tImpl?
Regards,
Edwin
According to the API specification,
javax.xml.parse rs.DocumentBuil der.parse should return an
org.w3c.dom.Doc ument. However, when I use the following code:
DocumentBuilder Factory factory = DocumentBuilder Factory.newInst ance();
factory.setVali dating(false);
factory.setName spaceAware(fals e);
DocumentBuilder builder = factory.newDocu mentBuilder();
ByteArrayInputS tream xmlIs = new
ByteArrayInputS tream(polisLijs t.getBytes());
Object parseReturn = builder.parse(x mlIs);
System.out.prin tln("######## ["+parseReturn.g etClass().getNa me()+"]
######");
Document xmlDoc = (Document) parseReturn;
the println prints:
######## [org.apache.xerc es.dom.Deferred DocumentImpl] ######
and the final statement gives an exception:
[java.lang.Class CastException]
[org.apache.xerc es.dom.Deferred DocumentImpl]
stack-trace=[java.lang.Class CastException: ...
Why do I get an DeferredDocumen tImpl when I should get a Document? Am
I doing something wrong? Or else: how do I create a Document from this
mysterious DeferredDocumen tImpl?
Regards,
Edwin
Comment