Search in sources :

Example 51 with XdmNodeReadTrx

use of org.sirix.api.XdmNodeReadTrx in project sirix by sirixdb.

the class ElementFilterTest method testFluentIterable.

@Test
public void testFluentIterable() throws SirixException {
    final XdmNodeReadTrx rtx = holder.getReader();
    final Iterator<Long> results = FluentIterable.from(new DescendantAxis(rtx)).filter(new ElementFilter(rtx)).limit(2).iterator();
    AbsAxisTest.testIterable(results, new long[] { 1, 5 });
}
Also used : XdmNodeReadTrx(org.sirix.api.XdmNodeReadTrx) DescendantAxis(org.sirix.axis.DescendantAxis) Test(org.junit.Test) AbsAxisTest(org.sirix.axis.AbsAxisTest)

Example 52 with XdmNodeReadTrx

use of org.sirix.api.XdmNodeReadTrx in project sirix by sirixdb.

the class NameFilterTest method testFilterConvetions.

@Test
public void testFilterConvetions() throws SirixException {
    final XdmNodeReadTrx rtx = holder.getReader();
    rtx.moveTo(9L);
    FilterTest.testFilterConventions(new NameFilter(rtx, "b"), true);
    rtx.moveTo(4L);
    FilterTest.testFilterConventions(new NameFilter(rtx, "b"), false);
    rtx.moveTo(7L);
    FilterTest.testFilterConventions(new NameFilter(rtx, "b"), false);
}
Also used : XdmNodeReadTrx(org.sirix.api.XdmNodeReadTrx) Test(org.junit.Test)

Example 53 with XdmNodeReadTrx

use of org.sirix.api.XdmNodeReadTrx in project sirix by sirixdb.

the class LevelOrderAxisTest method testAxisConventions.

@Test
public void testAxisConventions() throws SirixException {
    final XdmNodeReadTrx rtx = holder.getReader();
    rtx.moveTo(11L);
    AbsAxisTest.testIAxisConventions(new LevelOrderAxis.Builder(rtx).build(), new long[] { 12L });
    rtx.moveTo(11L);
    AbsAxisTest.testIAxisConventions(new LevelOrderAxis.Builder(rtx).includeSelf().build(), new long[] { 11L, 12L });
    rtx.moveTo(0L);
    AbsAxisTest.testIAxisConventions(new LevelOrderAxis.Builder(rtx).includeSelf().build(), new long[] { 0L, 1L, 4L, 5L, 8L, 9L, 13L, 6L, 7L, 11L, 12L });
    rtx.moveTo(4L);
    AbsAxisTest.testIAxisConventions(new LevelOrderAxis.Builder(rtx).includeSelf().build(), new long[] { 4L, 5L, 8L, 9L, 13L, 6L, 7L, 11L, 12L });
    rtx.moveTo(4L);
    AbsAxisTest.testIAxisConventions(new LevelOrderAxis.Builder(rtx).build(), new long[] { 5L, 8L, 9L, 13L, 6L, 7L, 11L, 12L });
    rtx.moveTo(6L);
    AbsAxisTest.testIAxisConventions(new LevelOrderAxis.Builder(rtx).build(), new long[] { 7L });
    rtx.moveTo(6L);
    AbsAxisTest.testIAxisConventions(new LevelOrderAxis.Builder(rtx).includeSelf().build(), new long[] { 6L, 7L });
    rtx.moveTo(2L);
    AbsAxisTest.testIAxisConventions(new LevelOrderAxis.Builder(rtx).includeSelf().build(), new long[] {});
    rtx.moveTo(3L);
    AbsAxisTest.testIAxisConventions(new LevelOrderAxis.Builder(rtx).includeSelf().build(), new long[] {});
    rtx.moveTo(2L);
    AbsAxisTest.testIAxisConventions(new LevelOrderAxis.Builder(rtx).build(), new long[] {});
    rtx.moveTo(3L);
    AbsAxisTest.testIAxisConventions(new LevelOrderAxis.Builder(rtx).build(), new long[] {});
    rtx.moveTo(6L);
    AbsAxisTest.testAxisConventionsNext(new LevelOrderAxis.Builder(rtx).includeSelf().build(), new long[] { 6L, 7L });
    rtx.moveTo(0L);
    AbsAxisTest.testAxisConventionsNext(new LevelOrderAxis.Builder(rtx).includeSelf().build(), new long[] { 0L, 1L, 4L, 5L, 8L, 9L, 13L, 6L, 7L, 11L, 12L });
    rtx.moveTo(0L);
    AbsAxisTest.testAxisConventionsNext(new LevelOrderAxis.Builder(rtx).includeSelf().includeNonStructuralNodes().build(), new long[] { 0L, 1L, 2L, 3L, 4L, 5L, 8L, 9L, 13L, 6L, 7L, 10L, 11L, 12L });
    rtx.moveTo(0L);
    AbsAxisTest.testIAxisConventions(new LevelOrderAxis.Builder(rtx).includeSelf().includeNonStructuralNodes().build(), new long[] { 0L, 1L, 2L, 3L, 4L, 5L, 8L, 9L, 13L, 6L, 7L, 10L, 11L, 12L });
}
Also used : XdmNodeReadTrx(org.sirix.api.XdmNodeReadTrx) Test(org.junit.Test)

Example 54 with XdmNodeReadTrx

use of org.sirix.api.XdmNodeReadTrx in project sirix by sirixdb.

the class NestedAxisTest method testNestedAxisTest3.

@Test
public void testNestedAxisTest3() throws SirixException {
    final XdmNodeReadTrx rtx = holder.getReader();
    // Find desceFndants starting from nodeKey 0L (root).
    rtx.moveToDocumentRoot();
    // XPath expression p:a/node():
    // Part: /p:a
    final Axis childA = new FilterAxis(new ChildAxis(rtx), new NameFilter(rtx, "p:a"));
    // Part: /node()
    final Axis childNode = new FilterAxis(new ChildAxis(rtx), new NodeFilter(rtx));
    // Part: /p:a/node():
    final Axis axis = new NestedAxis(childA, childNode);
    AbsAxisTest.testIAxisConventions(axis, new long[] { 4L, 5L, 8L, 9L, 13L });
}
Also used : NameFilter(org.sirix.axis.filter.NameFilter) XdmNodeReadTrx(org.sirix.api.XdmNodeReadTrx) FilterAxis(org.sirix.axis.filter.FilterAxis) Axis(org.sirix.api.Axis) FilterAxis(org.sirix.axis.filter.FilterAxis) NodeFilter(org.sirix.axis.filter.NodeFilter) Test(org.junit.Test)

Example 55 with XdmNodeReadTrx

use of org.sirix.api.XdmNodeReadTrx in project sirix by sirixdb.

the class NestedAxisTest method testNestedAxisTest2.

@Test
public void testNestedAxisTest2() throws SirixException {
    final XdmNodeReadTrx rtx = holder.getReader();
    // Find descendants starting from nodeKey 0L (root).
    rtx.moveToDocumentRoot();
    // XPath expression /[:a/b/@p:x]
    // Part: /p:a
    final Axis childA = new FilterAxis(new ChildAxis(rtx), new NameFilter(rtx, "p:a"));
    // Part: /b
    final Axis childB = new FilterAxis(new ChildAxis(rtx), new NameFilter(rtx, "b"));
    // Part: /@x
    final Axis attributeX = new FilterAxis(new AttributeAxis(rtx), new NameFilter(rtx, "p:x"));
    // Part: /p:a/b/@p:x
    final Axis axis = new NestedAxis(new NestedAxis(childA, childB), attributeX);
    AbsAxisTest.testIAxisConventions(axis, new long[] { 10L });
}
Also used : NameFilter(org.sirix.axis.filter.NameFilter) XdmNodeReadTrx(org.sirix.api.XdmNodeReadTrx) FilterAxis(org.sirix.axis.filter.FilterAxis) Axis(org.sirix.api.Axis) FilterAxis(org.sirix.axis.filter.FilterAxis) Test(org.junit.Test)

Aggregations

XdmNodeReadTrx (org.sirix.api.XdmNodeReadTrx)150 Test (org.junit.Test)93 XdmNodeWriteTrx (org.sirix.api.XdmNodeWriteTrx)48 QNm (org.brackit.xquery.atomic.QNm)20 DescendantAxis (org.sirix.axis.DescendantAxis)17 Iterator (java.util.Iterator)16 ResourceManager (org.sirix.api.ResourceManager)14 Axis (org.sirix.api.Axis)13 DBNode (org.sirix.xquery.node.DBNode)12 QueryException (org.brackit.xquery.QueryException)11 FilterAxis (org.sirix.axis.filter.FilterAxis)11 IndexController (org.sirix.access.IndexController)10 IndexDef (org.sirix.index.IndexDef)10 Item (org.brackit.xquery.xdm.Item)7 Database (org.sirix.api.Database)7 SirixException (org.sirix.exception.SirixException)6 NonStructuralWrapperAxis (org.sirix.axis.NonStructuralWrapperAxis)5 SirixDeweyID (org.sirix.node.SirixDeweyID)5 Path (java.nio.file.Path)4 AbsAxisTest (org.sirix.axis.AbsAxisTest)4