Wrapping XML stream reader that reads a single element from the underlying stream.
It will generate START_DOCUMENT and END_DOCUMENT events as required to make
the sequence of events appear as a complete document.
Assume for example that the parent reader is parsing the following document:
<a><b>text</b></a>
If the current event is
<b>
when the wrapper is created, it will produce
the following sequence of events:
- A synthetic START_DOCUMENT event.
- START_ELEMENT, CHARACTERS and END_ELEMENT events for
<b>text</b>
.
For these events, the wrapper directly delegates to the parent reader.
- A synthetic END_DOCUMENT event.
After all events have been consumed from the wrapper, the current event on the parent reader
will be the event following the last END_ELEMENT of the fragment. In the example above this
will be
</a>
.
The wrapper will release the reference to the parent reader when
#close() is called.
For obvious reasons, the wrapper will never call
XMLStreamReader#close() on the parent
reader.