public XMLStreamReader getItemAsStream() throws XQException {
// The spec (section 12.1) requires that the item be converted into a document, and we
// then read events corresponding to this document
checkNotClosed();
PipelineConfiguration pipe = config.makePipelineConfiguration();
pipe.setHostLanguage(Configuration.XQUERY);
if (item instanceof DocumentInfo) {
EventIterator eventIterator = new Decomposer((NodeInfo)item, pipe);
return new EventToStaxBridge(eventIterator, pipe);
} else {
EventIterator contentIterator = new SingletonEventIterator(item);