use of org.sirix.axis.DescendantAxis in project sirix by sirixdb.
the class UpdateTest method testThirdMoveToFirstChild.
@Test
public void testThirdMoveToFirstChild() throws SirixException {
final XdmNodeWriteTrx wtx = holder.getResourceManager().beginNodeWriteTrx();
DocumentCreater.create(wtx);
wtx.moveTo(5);
wtx.moveSubtreeToFirstChild(11);
testThirdMoveToFirstChild(wtx);
wtx.commit();
testThirdMoveToFirstChild(wtx);
wtx.close();
final XdmNodeReadTrx rtx = holder.getResourceManager().beginNodeReadTrx();
testThirdMoveToFirstChild(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.3")).add(new SirixDeweyID("1.3.5")).add(new SirixDeweyID("1.3.5.2.3")).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.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 testFirstMoveToFirstChild.
@Test
public void testFirstMoveToFirstChild() throws SirixException {
final XdmNodeWriteTrx wtx = holder.getResourceManager().beginNodeWriteTrx();
DocumentCreater.create(wtx);
wtx.moveTo(7);
wtx.moveSubtreeToFirstChild(6);
testFirstMoveToFirstChild(wtx);
wtx.commit();
testFirstMoveToFirstChild(wtx);
wtx.close();
final XdmNodeReadTrx rtx = holder.getResourceManager().beginNodeReadTrx();
testFirstMoveToFirstChild(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.3")).add(new SirixDeweyID("1.3.5")).add(new SirixDeweyID("1.3.5.5")).add(new SirixDeweyID("1.3.5.5.3")).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 testFirstMoveSubtreeToRightSibling.
@Test
public void testFirstMoveSubtreeToRightSibling() throws SirixException {
final XdmNodeWriteTrx wtx = holder.getResourceManager().beginNodeWriteTrx();
DocumentCreater.create(wtx);
wtx.moveToDocumentRoot();
for (final long nodeKey : new NonStructuralWrapperAxis(new DescendantAxis(wtx, IncludeSelf.YES))) {
System.out.println(nodeKey + ": " + wtx.getDeweyID());
}
wtx.moveTo(7);
wtx.moveSubtreeToRightSibling(6);
testFirstMoveSubtreeToRightSibling(wtx);
wtx.moveToDocumentRoot();
for (final long nodeKey : new NonStructuralWrapperAxis(new DescendantAxis(wtx, IncludeSelf.YES))) {
System.out.println(nodeKey + ": " + wtx.getDeweyID());
}
wtx.commit();
wtx.moveToDocumentRoot();
for (final long nodeKey : new NonStructuralWrapperAxis(new DescendantAxis(wtx, IncludeSelf.YES))) {
System.out.println(nodeKey + ": " + wtx.getDeweyID());
}
testFirstMoveSubtreeToRightSibling(wtx);
wtx.close();
final XdmNodeReadTrx rtx = holder.getResourceManager().beginNodeReadTrx();
testFirstMoveSubtreeToRightSibling(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.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.close();
}
use of org.sirix.axis.DescendantAxis in project sirix by sirixdb.
the class XPathParser method parsePathExpr.
/**
* Parses the the rule PathExpr according to the following production rule:
* <p>
* [25] PathExpr ::= ("/" RelativePathExpr?) | ("//" RelativePathExpr) | RelativePathExpr .
* </p>
*
* @throws SirixXPathException
*/
private void parsePathExpr() throws SirixXPathException {
if (is(TokenType.SLASH, true)) {
// path expression starts from the root
mPipeBuilder.addStep(new DocumentNodeAxis(getTransaction()));
final TokenType type = mToken.getType();
if (type != TokenType.END && type != TokenType.COMMA) {
// all immediately following keywords or '*' are nametests, not
// operators
// leading-lone-slash constrain
parseRelativePathExpr();
}
} else if (is(TokenType.DESC_STEP, true)) {
// path expression starts from the root with a descendant-or-self
// step
mPipeBuilder.addStep(new DocumentNodeAxis(getTransaction()));
final Axis mAxis = new DescendantAxis(getTransaction(), IncludeSelf.YES);
mPipeBuilder.addStep(mAxis);
parseRelativePathExpr();
} else {
parseRelativePathExpr();
}
}
use of org.sirix.axis.DescendantAxis in project sirix by sirixdb.
the class XPathParser method parseForwardAxis.
/**
* Parses the the rule ForwardAxis according to the following production rule:
* <p>
* [30] ForwardAxis ::= <"child" "::"> | <"descendant" "::"> | <"attribute" "::"> | <"self" "::">
* | <"descendant-or-self" "::"> | <"following-sibling" "::"> | <"following" "::"> | <"namespace"
* "::"> .
* </p>
*
* @return axis
* @throws SirixXPathException
*/
private Axis parseForwardAxis() throws SirixXPathException {
final Axis axis;
if (is("child", true)) {
axis = new ChildAxis(getTransaction());
} else if (is("descendant", true)) {
axis = new DescendantAxis(getTransaction());
} else if (is("descendant-or-self", true)) {
axis = new DescendantAxis(getTransaction(), IncludeSelf.YES);
} else if (is("attribute", true)) {
axis = new AttributeAxis(getTransaction());
} else if (is("self", true)) {
axis = new SelfAxis(getTransaction());
} else if (is("following", true)) {
axis = new FollowingAxis(getTransaction());
} else if (is("following-sibling", true)) {
axis = new FollowingSiblingAxis(getTransaction());
} else {
is("namespace", true);
throw EXPathError.XPST0010.getEncapsulatedException();
}
consume(TokenType.COLON, true);
consume(TokenType.COLON, true);
return axis;
}
Aggregations