### Question:
BagriXQItemAccessor extends BagriXQCloseable implements XQItemAccessor { @Override public Node getNode() throws XQException { checkState(ex_item_closed); switch (type.getItemKind()) { case XQITEMKIND_ATTRIBUTE: case XQITEMKIND_SCHEMA_ATTRIBUTE: return (org.w3c.dom.Attr) value; case XQITEMKIND_COMMENT: return (org.w3c.dom.Comment) value; case XQITEMKIND_DOCUMENT: return (org.w3c.dom.Document) value; case XQITEMKIND_ELEMENT: case XQITEMKIND_DOCUMENT_ELEMENT: case XQITEMKIND_DOCUMENT_SCHEMA_ELEMENT: case XQITEMKIND_SCHEMA_ELEMENT: return (org.w3c.dom.Element) value; case XQITEMKIND_PI: return (org.w3c.dom.ProcessingInstruction) value; case XQITEMKIND_TEXT: return (org.w3c.dom.Text) value; default: throw new XQException("ItemType is not Node: " + value.getClass().getName()); } } BagriXQItemAccessor(XQProcessor xqProcessor); @Override boolean getBoolean(); @Override byte getByte(); @Override double getDouble(); @Override float getFloat(); @Override int getInt(); @Override XQItemType getItemType(); @Override String getAtomicValue(); @Override long getLong(); @Override Node getNode(); @Override URI getNodeUri(); @Override Object getObject(); @Override XMLStreamReader getItemAsStream(); @Override String getItemAsString(Properties props); @Override short getShort(); @Override boolean instanceOf(XQItemType type); @Override void writeItem(OutputStream os, Properties props); @Override void writeItem(Writer ow, Properties props); @Override void writeItemToSAX(ContentHandler saxhdlr); @Override void writeItemToResult(Result result);  }### Answer:
@Test public void testGetNode() throws XQException, ParserConfigurationException, SAXException, IOException { Node node = null; XQExpression xqe = xqc.createExpression(); XQSequence xqs = xqe.executeQuery("<e/>, <e a=''/>/@*"); xqs.next(); try { node = xqs.getNode(); } catch (XQException e) { fail("A-XQIA-3.1: getNode on element() failed with message: " + e.getMessage()); } assertEquals("A-XQIA-3.1: getNode on element() failed", true, node instanceof Element); assertEquals("A-XQIA-3.1: getNode on element() failed", "e", node.getLocalName()); xqs.next(); try { node = xqs.getNode(); } catch (XQException e) { fail("A-XQIA-3.1: getNode on attribute() failed with message: " + e.getMessage()); } assertEquals("A-XQIA-3.1: getNode on attribute() failed", true, node instanceof Attr); assertEquals("A-XQIA-3.1: getNode on attribute() failed", "a", node.getLocalName()); xqe.close(); DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder parser = factory.newDocumentBuilder(); Document document = parser.parse(new InputSource(new StringReader("<e>Hello world!</e>"))); XQItem xqi = null; try { xqi = xqc.createItemFromNode(document, null); } catch (XQException e) { fail("A-XQDF-1.5: createItemFromNode() 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); }