### Question:
BagriXQSequence extends BagriXQItemAccessor implements XQSequence { @Override public void writeSequence(OutputStream os, Properties props) throws XQException { checkState(ex_sequence_closed); if (os == null) { throw new XQException("Provided OutputStream is null"); } String result = getSequenceAsString(props); try { os.write(result.getBytes()); } 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 testWriteSequence() throws XQException { XQExpression xqe = xqc.createExpression(); XQSequence xqs = xqe.executeQuery("<e>Hello world!</e>"); StringWriter result = new StringWriter(); Properties prop = new Properties(); prop.setProperty("encoding", "UTF-8"); try { xqs.writeSequence(result, prop); } catch (XQException e) { fail("A-XQS-24.1: writeSequence failed with message: " + e.getMessage()); } assertTrue("A-XQS-24.1: Expects serialized result contains '<e>Hello world!</e>', but it is '" + result.toString() + "'", result.toString().indexOf("<e>Hello world!</e>") != -1); xqe.close(); }