StaxMate icon indicating copy to clipboard operation
StaxMate copied to clipboard

Consider wrapping returned `XMLStreamReader2` instance, to catch calls to 'next()' (etc)

Open cowtowncoder opened this issue 13 years ago • 0 comments

Currently it is possible that user by-passes cursors for direct access using XMLStreamReader2 accessors. This is sort of by design, since there are things that are difficult to cleanly expose, as well as to keep StaxMate API relatively simple.

Now: most access is fine as is and not problematic. But there is small subset of calls that can cause issues to cursor synchronization. The most obvious is XMLStreamReader.next() (and probably easiest one to handle as well), but others that are equally difficult are things that indirectly advance stream, like:

  • getElementText()
  • getElementAsXxx()
  • readElementAsXxx()

It would however be relatively easy to use a wrapper around "native" stream reader before returning it; and make this wrapper connect back to cursor(s), so that StaxMate could try to keep things nicely synchronized.

Whether this would actually work is unproven, but the basic idea seems sound.

cowtowncoder avatar Feb 19 '13 21:02 cowtowncoder