public XQItem createItemFromDocument(XMLStreamReader value, XQItemType type) throws XQException {
checkNotClosed();
SaxonXQDataSource.checkNotNull(value, "value");
try {
StaxToEventBridge bridge = new StaxToEventBridge();
bridge.setXMLStreamReader(value);
bridge.setPipelineConfiguration(getConfiguration().makePipelineConfiguration());
Source ss = new PullEventSource(bridge);
ss = augmentSource(ss, type);
DocumentInfo doc = getConfiguration().buildDocument(ss);
checkDocumentType(doc, (SaxonXQItemType)type);
return new SaxonXQItem(doc, this);