Details
Description
If you create an XMLEventReader from a W3CDOMStreamReader (with the woodstox library), it will fail because XMLEventAllocator doesnt accept Attribute XMLEvent :
Caused by: com.ctc.wstx.exc.WstxException: Internal error: should not get [13]
at com.ctc.wstx.evt.DefaultEventAllocator.allocate(DefaultEventAllocator.java:256)
at org.codehaus.stax2.ri.Stax2EventReaderImpl.createNextEvent(Stax2EventReaderImpl.java:411)
at org.codehaus.stax2.ri.Stax2EventReaderImpl.nextEvent(Stax2EventReaderImpl.java:255)
Here is the comment in wstx source code :
------------8<-----------8<-----------8<-----------8<-----------8<------------
/* Following 2 types should never get in here; they are directly
- handled by the reader, and can only be accessed via start
- element.
*/
case NAMESPACE:
case ATTRIBUTE:
throw new WstxException("Internal error: should not get "
+ErrorConsts.tokenTypeDesc(r.getEventType()));
------------8<-----------8<-----------8<-----------8<-----------8<------------
To create a XMLStreamReader from a DOM Document or Node, i recommand to simply use XMLInputFactory.createStreamReader(source), where source is a DOMSource.
I think it's better to rely on stax implementation to create a StreamReader from a DOM Node.