use of net.sf.saxon.om.NamePool in project sirix by sirixdb.
the class NodeWrapper method getDeclaredNamespaces.
@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 the supplied array is larger than required, then the first
* unused entry will be set to -1.
*/
if (count < retVal.length) {
retVal[count] = -1;
}
}
} catch (final SirixException e) {
throw new IllegalStateException(e.getCause());
}
}
return retVal;
}
Aggregations