### Question:
BagriXQSequence extends BagriXQItemAccessor implements XQSequence { @Override public XMLStreamReader getSequenceAsStream() throws XQException { checkState(ex_sequence_closed); try { return XMLUtils.stringToStream(getSequenceAsString(null)); } catch (IOException ex) { throw new XQException(ex.getMessage()); } } BagriXQSequence(BagriXQDataFactory xqFactory, XQProcessor xqProcessor); @Override XQItem getItem(); @Override XMLStreamReader getSequenceAsStream(); @Override String getSequenceAsString(Properties props); @Override void writeSequence(OutputStream os, Properties props); @Override void writeSequence(Writer ow, Properties props); @Override void writeSequenceToSAX(ContentHandler saxhdlr); @Override void writeSequenceToResult(Result result);  }### Answer:
@Test public void testBindSequence() throws XQException { XQExpression xqe = xqc.createExpression(); boolean failed = false; try { XQSequence xqs = xqe.executeQuery("<e>Hello world!</e>"); XQItem xqitem = xqc.createItemFromDocument(xqs.getSequenceAsStream(), xqc.createAtomicType(XQItemType.XQBASETYPE_BOOLEAN)); if (xqitem.getItemType().getItemKind() != XQItemType.XQITEMKIND_ATOMIC) failed = true; if (xqitem.getItemType().getBaseType() != XQItemType.XQBASETYPE_BOOLEAN) failed = true; } catch (XQException e) { } if (failed) fail("A-XQDF-1.3: The conversion is subject to the following constraints. Either it fails with an XQException, either it is successful in which case it must result in an instance of XDT."); XQItem xqi = null; try { XQSequence xqs = xqe.executeQuery("<e>Hello world!</e>"); xqi = xqc.createItemFromDocument(xqs.getSequenceAsStream(), null); } catch (XQException e) { fail("A-XQDF-1.5: createItemFromDocument() failed with message: " + e.getMessage()); } String result = xqi.getItemAsString(null); assertTrue("A-XQDF-1.5: Expects serialized result contains '<e>Hello world!</e>', but it is '" + result + "'", result.indexOf("<e>Hello world!</e>") != -1); xqe.close(); }