NodeWrapper implements SiblingCountingNode { @Override public int[] getDeclaredNamespaces(final int[] buffer) { int[] retVal = null; if (mNodeKind == Kind.ELEMENT) { try { final NodeReadTrx rtx = createRtxAndMove(); final int count = rtx.getNamespaceCount(); if (count == 0) { retVal = EMPTY_NAMESPACE_LIST; } else { retVal = (buffer == null || count > buffer.length ? new int[count] : buffer); final NamePool pool = getNamePool(); int n = 0; try { for (int i = 0; i < count; i++) { rtx.moveTo(i); final String prefix = getPrefix(); final String uri = getURI(); rtx.moveTo(mKey); retVal[n++] = pool.allocateNamespaceCode(prefix, uri); } rtx.close(); } catch (final SirixException exc) { LOGGER.error(exc.toString()); } if (count < retVal.length) { retVal[count] = -1; } } } catch (final SirixException e) { throw new IllegalStateException(e.getCause()); } } return retVal; } NodeWrapper(final DocumentWrapper docWrapper, final long nodeKeyToStart); @Override Value atomize(); @Override int compareOrder(final NodeInfo node); void copy(final Receiver out, final int copyOption,
			final int locationId); @Override void generateId(final FastStringBuffer buf); @Override String getAttributeValue(final int fingerprint); @Override String getBaseURI(); @Override int getColumnNumber(); @Override Configuration getConfiguration(); @Override int[] getDeclaredNamespaces(final int[] buffer); @Override String getDisplayName(); @Override long getDocumentNumber(); @Override DocumentInfo getDocumentRoot(); @Override int getFingerprint(); @Override int getLineNumber(); @Override String getLocalPart(); @Override int getNameCode(); @Override NamePool getNamePool(); @Override int getNodeKind(); @Override NodeInfo getParent(); @Override String getPrefix(); @Override NodeInfo getRoot(); @Override final String getStringValue(); @Override final CharSequence getStringValueCS(); @Override String getSystemId(); int getTypeAnnotation(); @Override String getURI(); @Override boolean hasChildNodes(); @Override boolean isId(); @Override boolean isIdref(); @Override boolean isNilled(); @Override boolean isSameNodeInfo(final NodeInfo pOther); @Override AxisIterator iterateAxis(final byte axisNumber); @Override AxisIterator iterateAxis(final byte axisNumber, final NodeTest nodeTest); @Override void setSystemId(final String systemId); @Override SequenceIterator getTypedValue(); @Override int getSiblingPosition(); long getKey();  }
@Test public void testGetDeclaredNamespaces() { final AxisIterator iterator = node.iterateAxis(Axis.CHILD); node = (NodeWrapper) iterator.next(); final int[] namespaces = node.getDeclaredNamespaces(new int[1]); node.getNamePool().allocateNamespaceCode("p", "ns"); final int expected = node.getNamePool().getNamespaceCode("p", "ns"); assertEquals(expected, namespaces[0]); final AxisIterator iter = node.iterateAxis(Axis.DESCENDANT); node = (NodeWrapper) iter.next(); node = (NodeWrapper) iter.next(); final int[] namesp = node.getDeclaredNamespaces(new int[1]); assertTrue(namesp.length == 0); final AxisIterator it = node.iterateAxis(Axis.DESCENDANT); node = (NodeWrapper) it.next(); assertNull(node.getDeclaredNamespaces(new int[1])); }