use of org.sirix.axis.DescendantAxis in project sirix by sirixdb.
the class IndexBuilder method build.
/**
* Build the index.
*
* @param rtx the current {@link XdmNodeReadTrx}
* @param builders the index builders
*/
public static void build(final XdmNodeReadTrx rtx, final Set<Visitor> builders) {
final long nodeKey = rtx.getNodeKey();
rtx.moveToDocumentRoot();
for (@SuppressWarnings("unused") final long key : new NonStructuralWrapperAxis(new DescendantAxis(rtx))) {
for (final Visitor builder : builders) {
rtx.acceptVisitor(builder);
}
}
rtx.moveTo(nodeKey);
}
use of org.sirix.axis.DescendantAxis in project sirix by sirixdb.
the class DocumentWrapper method selectID.
@Override
public NodeInfo selectID(final String ID, final boolean getParent) {
try {
final NodeReadTrx rtx = mSession.beginNodeReadTrx();
final Axis axis = new DescendantAxis(rtx, IncludeSelf.YES);
while (axis.hasNext()) {
if (rtx.getKind() == Kind.ELEMENT) {
final int attCount = rtx.getAttributeCount();
if (attCount > 0) {
final long nodeKey = rtx.getNodeKey();
for (int index = 0; index < attCount; index++) {
rtx.moveToAttribute(index);
if ("xml:id".equalsIgnoreCase(rtx.getName().getLocalName()) && ID.equals(rtx.getValue())) {
if (getParent) {
rtx.moveToParent();
}
return new NodeWrapper(this, rtx.getNodeKey());
}
rtx.moveTo(nodeKey);
}
}
}
axis.next();
}
rtx.close();
} catch (final SirixException e) {
LOGWRAPPER.error(e.getMessage(), e);
}
return null;
}
use of org.sirix.axis.DescendantAxis in project sirix by sirixdb.
the class DBNode method expandString.
/**
* Filter text nodes.
*
* @return concatenated String of text node values
*/
private String expandString() {
final StringBuilder buffer = new StringBuilder();
final Axis axis = new DescendantAxis(mRtx);
while (axis.hasNext()) {
axis.next();
if (mRtx.isText()) {
buffer.append(mRtx.getValue());
}
}
return buffer.toString();
}
use of org.sirix.axis.DescendantAxis in project sirix by sirixdb.
the class UpdateTest method testSecondMoveToFirstChild.
@Test
public void testSecondMoveToFirstChild() throws SirixException {
final XdmNodeWriteTrx wtx = holder.getResourceManager().beginNodeWriteTrx();
DocumentCreater.create(wtx);
wtx.moveTo(5);
wtx.moveSubtreeToFirstChild(4);
testSecondMoveToFirstChild(wtx);
wtx.commit();
testSecondMoveToFirstChild(wtx);
wtx.close();
final XdmNodeReadTrx rtx = holder.getResourceManager().beginNodeReadTrx();
testSecondMoveToFirstChild(rtx);
rtx.moveToDocumentRoot();
final Builder<SirixDeweyID> builder = ImmutableSet.<SirixDeweyID>builder();
final ImmutableSet<SirixDeweyID> ids = builder.add(new SirixDeweyID("1")).add(new SirixDeweyID("1.3")).add(new SirixDeweyID("1.3.0.3")).add(new SirixDeweyID("1.3.1.3")).add(new SirixDeweyID("1.3.5")).add(new SirixDeweyID("1.3.5.3")).add(new SirixDeweyID("1.3.5.5")).add(new SirixDeweyID("1.3.7")).add(new SirixDeweyID("1.3.9")).add(new SirixDeweyID("1.3.9.1.3")).add(new SirixDeweyID("1.3.9.3")).add(new SirixDeweyID("1.3.9.5")).add(new SirixDeweyID("1.3.11")).build();
test(ids.iterator(), new NonStructuralWrapperAxis(new DescendantAxis(rtx, IncludeSelf.YES)));
rtx.close();
}
use of org.sirix.axis.DescendantAxis in project sirix by sirixdb.
the class UpdateTest method testSecondMoveSubtreeToRightSibling.
@Test
public void testSecondMoveSubtreeToRightSibling() throws SirixException {
final XdmNodeWriteTrx wtx = holder.getResourceManager().beginNodeWriteTrx();
DocumentCreater.create(wtx);
wtx.moveTo(9);
wtx.moveSubtreeToRightSibling(5);
// wtx.moveTo(5);
// wtx.moveSubtreeToRightSibling(4);
testSecondMoveSubtreeToRightSibling(wtx);
wtx.commit();
testSecondMoveSubtreeToRightSibling(wtx);
wtx.close();
final XdmNodeReadTrx rtx = holder.getResourceManager().beginNodeReadTrx();
testSecondMoveSubtreeToRightSibling(rtx);
rtx.moveToDocumentRoot();
final Builder<SirixDeweyID> builder = ImmutableSet.<SirixDeweyID>builder();
builder.add(new SirixDeweyID("1")).add(new SirixDeweyID("1.3")).add(new SirixDeweyID("1.3.0.3")).add(new SirixDeweyID("1.3.1.3")).add(new SirixDeweyID("1.3.3")).add(new SirixDeweyID("1.3.5")).add(new SirixDeweyID("1.3.5.5")).add(new SirixDeweyID("1.3.5.7")).add(new SirixDeweyID("1.3.7")).add(new SirixDeweyID("1.3.9")).add(new SirixDeweyID("1.3.9.1.3")).add(new SirixDeweyID("1.3.9.3")).add(new SirixDeweyID("1.3.9.5")).add(new SirixDeweyID("1.3.11")).build();
// test(ids.iterator(), new NonStructuralWrapperAxis(new DescendantAxis(rtx,
// IncludeSelf.YES)));
rtx.moveToDocumentRoot();
for (final long nodeKey : new NonStructuralWrapperAxis(new DescendantAxis(rtx, IncludeSelf.YES))) {
System.out.println(nodeKey + ": " + rtx.getDeweyID());
}
rtx.close();
}
Aggregations