Search in sources :

Example 26 with XPathAxis

use of org.sirix.service.xml.xpath.XPathAxis in project sirix by sirixdb.

the class ConXPathAxisTest method testAncestor.

@Test
public void testAncestor() {
    try {
        // Find ancestor starting from nodeKey 8L.
        holder.getReader().moveTo(11L);
        AbsAxisTest.testIAxisConventions(new XPathAxis(holder.getReader(), "ancestor::p:a"), new long[] { 1L });
        holder.getReader().moveTo(13L);
        AbsAxisTest.testIAxisConventions(new XPathAxis(holder.getReader(), "ancestor::p:a"), new long[] { 1L });
        holder.getReader().moveTo(11L);
        AbsAxisTest.testIAxisConventions(new XPathAxis(holder.getReader(), "ancestor::node()"), new long[] { 9L, 1L });
        holder.getReader().moveTo(11L);
        AbsAxisTest.testIAxisConventions(new XPathAxis(holder.getReader(), "ancestor-or-self::node()"), new long[] { 11L, 9L, 1L });
    } catch (final SirixXPathException mExp) {
        mExp.getStackTrace();
    }
}
Also used : SirixXPathException(org.sirix.exception.SirixXPathException) XPathAxis(org.sirix.service.xml.xpath.XPathAxis) Test(org.junit.Test) AbsAxisTest(org.sirix.axis.AbsAxisTest)

Example 27 with XPathAxis

use of org.sirix.service.xml.xpath.XPathAxis in project sirix by sirixdb.

the class ConXPathAxisTest method testMultiExpr.

@Test
public void testMultiExpr() {
    try {
        holder.getReader().moveTo(1L);
        AbsAxisTest.testIAxisConventions(new XPathAxis(holder.getReader(), "b, b, b"), new long[] { 5L, 9L, 5L, 9L, 5L, 9L });
        AbsAxisTest.testIAxisConventions(new XPathAxis(holder.getReader(), "b/c, ., //c"), new long[] { 7L, 11L, 1L, 7L, 11L });
        AbsAxisTest.testIAxisConventions(new XPathAxis(holder.getReader(), "b/text(), //text(), descendant-or-self::element()"), new long[] { 6L, 12L, 4L, 8L, 13L, 6L, 12L, 1L, 5L, 7L, 9L, 11L });
        holder.getReader().moveTo(5L);
        AbsAxisTest.testIAxisConventions(new XPathAxis(holder.getReader(), "/p:a/b/c, ., .., .//text()"), new long[] { 7L, 11L, 5L, 1L, 6L });
    } catch (final SirixXPathException mExp) {
        mExp.getStackTrace();
    }
}
Also used : SirixXPathException(org.sirix.exception.SirixXPathException) XPathAxis(org.sirix.service.xml.xpath.XPathAxis) Test(org.junit.Test) AbsAxisTest(org.sirix.axis.AbsAxisTest)

Example 28 with XPathAxis

use of org.sirix.service.xml.xpath.XPathAxis in project sirix by sirixdb.

the class ConXPathAxisTest method testPosition.

@Test
public void testPosition() {
    try {
        // Find descendants starting from nodeKey 0L (root).
        holder.getReader().moveTo(1L);
        AbsAxisTest.testIAxisConventions(new XPathAxis(holder.getReader(), "b"), new long[] { 5L, 9L });
        AbsAxisTest.testIAxisConventions(new XPathAxis(holder.getReader(), "b/c"), new long[] { 7L, 11L });
        AbsAxisTest.testIAxisConventions(new XPathAxis(holder.getReader(), "b/text()"), new long[] { 6L, 12L });
        AbsAxisTest.testIAxisConventions(new XPathAxis(holder.getReader(), "/p:a/b/c"), new long[] { 7L, 11L });
    } catch (final SirixXPathException mExp) {
        mExp.getStackTrace();
    }
}
Also used : SirixXPathException(org.sirix.exception.SirixXPathException) XPathAxis(org.sirix.service.xml.xpath.XPathAxis) Test(org.junit.Test) AbsAxisTest(org.sirix.axis.AbsAxisTest)

Example 29 with XPathAxis

use of org.sirix.service.xml.xpath.XPathAxis in project sirix by sirixdb.

the class ConXPathAxisTest method testSteps.

@Test
public void testSteps() {
    try {
        AbsAxisTest.testIAxisConventions(new XPathAxis(holder.getReader(), "/text:p/b"), new long[] {});
        AbsAxisTest.testIAxisConventions(new XPathAxis(holder.getReader(), "/p:a/b"), new long[] { 5L, 9L });
        AbsAxisTest.testIAxisConventions(new XPathAxis(holder.getReader(), "/p:a/b/c"), new long[] { 7L, 11L });
        AbsAxisTest.testIAxisConventions(new XPathAxis(holder.getReader(), "/p:a"), new long[] { 1L });
        AbsAxisTest.testIAxisConventions(new XPathAxis(holder.getReader(), "child::p:a/child::b"), new long[] { 5L, 9L });
        AbsAxisTest.testIAxisConventions(new XPathAxis(holder.getReader(), "child::p:" + "a/child::b/child::c"), new long[] { 7L, 11L });
    } catch (final SirixXPathException mExp) {
        mExp.getStackTrace();
    }
}
Also used : SirixXPathException(org.sirix.exception.SirixXPathException) XPathAxis(org.sirix.service.xml.xpath.XPathAxis) Test(org.junit.Test) AbsAxisTest(org.sirix.axis.AbsAxisTest)

Example 30 with XPathAxis

use of org.sirix.service.xml.xpath.XPathAxis in project sirix by sirixdb.

the class ConXPathAxisTest method testUnabbreviate.

@Test
public void testUnabbreviate() {
    try {
        // Find descendants starting from nodeKey 0L (root).
        holder.getReader().moveTo(1L);
        AbsAxisTest.testIAxisConventions(new XPathAxis(holder.getReader(), "child::b"), new long[] { 5L, 9L });
        AbsAxisTest.testIAxisConventions(new XPathAxis(holder.getReader(), "child::*"), new long[] { 5L, 9L });
        AbsAxisTest.testIAxisConventions(new XPathAxis(holder.getReader(), "child::text()"), new long[] { 4L, 8L, 13L });
        AbsAxisTest.testIAxisConventions(new XPathAxis(holder.getReader(), "attribute::i"), new long[] { 3L });
        AbsAxisTest.testIAxisConventions(new XPathAxis(holder.getReader(), "attribute::*"), new long[] { 3L });
        AbsAxisTest.testIAxisConventions(new XPathAxis(holder.getReader(), "parent::node()"), new long[] { 0L });
        AbsAxisTest.testIAxisConventions(new XPathAxis(holder.getReader(), "self::blau"), new long[] {});
        AbsAxisTest.testIAxisConventions(new XPathAxis(holder.getReader(), "/"), new long[] { 0L });
        // IAxisTest.testIAxisConventions(new XPathAxis(holder.getRtx(),
        // "child::b[fn:position() = 1]"), new long[] { 4L });
        // 
        // // IAxisTest.testIAxisConventions(new XPathAxis(
        // holder.getRtx(), "child::b[fn:position() = fn:last()]"), new
        // long[] {8L});
        // 
        // IAxisTest.testIAxisConventions(new XPathAxis(
        // holder.getRtx(), "child::b[fn:position() = fn:last()-1]"), new
        // long[] {4L});
        // 
        // IAxisTest.testIAxisConventions(new XPathAxis(holder.getRtx(),
        // "child::b[fn:position() > 1]"), new long[] { 8L });
        AbsAxisTest.testIAxisConventions(new XPathAxis(holder.getReader(), "child::b[attribute::p:x = \"y\"]"), new long[] { 9L });
        // IAxisTest.testIAxisConventions(new XPathAxis(holder.getRtx(),
        // "child::b[attribute::p:x = \"y\"][fn:position() = 1]"),
        // new long[] { 8L });
        // IAxisTest.testIAxisConventions(new XPathAxis(holder.getRtx(),
        // "child::b[attribute::p:x = \"y\"][1]"), new long[] { 8L });
        // IAxisTest.testIAxisConventions(new XPathAxis(holder.getRtx(),
        // "child::b[attribute::p:x = \"y\"][fn:position() = 3]"), new
        // long[]
        // {});
        // IAxisTest.testIAxisConventions(new XPathAxis(holder.getRtx(),
        // "child::b[attribute::p:x = \"y\"][3]"), new long[] {});
        // IAxisTest.testIAxisConventions(new XPathAxis(holder.getRtx(),
        // "child::b[fn:position() = 2][attribute::p:x = \"y\"]"),
        // new long[] { 8L });
        AbsAxisTest.testIAxisConventions(new XPathAxis(holder.getReader(), "child::b[child::c]"), new long[] { 5L, 9L });
        AbsAxisTest.testIAxisConventions(new XPathAxis(holder.getReader(), "child::*[text() or c]"), new long[] { 5l, 9L });
        // IAxisTest.testIAxisConventions(new XPathAxis(
        // holder.getRtx(),
        // "child::*[text() or c][fn:position() = fn:last()]"), new long[]
        // {8L});
        AbsAxisTest.testIAxisConventions(new XPathAxis(holder.getReader(), "child::*[text() or c], /node(), //c"), new long[] { 5l, 9L, 1L, 7L, 11L });
    } catch (final SirixXPathException mExp) {
        mExp.getStackTrace();
    }
}
Also used : SirixXPathException(org.sirix.exception.SirixXPathException) XPathAxis(org.sirix.service.xml.xpath.XPathAxis) Test(org.junit.Test) AbsAxisTest(org.sirix.axis.AbsAxisTest)

Aggregations

XPathAxis (org.sirix.service.xml.xpath.XPathAxis)67 Test (org.junit.Test)62 Ignore (org.junit.Ignore)27 AbsAxisTest (org.sirix.axis.AbsAxisTest)18 SirixXPathException (org.sirix.exception.SirixXPathException)12 AbstractAxis (org.sirix.service.xml.xpath.AbstractAxis)12 Axis (org.sirix.api.Axis)6 IOException (java.io.IOException)3 WebApplicationException (javax.ws.rs.WebApplicationException)3 SessionConfiguration (org.sirix.access.conf.SessionConfiguration)3 Database (org.sirix.api.Database)3 NodeReadTrx (org.sirix.api.NodeReadTrx)3 Session (org.sirix.api.Session)3 SirixException (org.sirix.exception.SirixException)3 XPathError (org.sirix.service.xml.xpath.XPathError)3 XdmNodeReadTrx (org.sirix.api.XdmNodeReadTrx)2 LinkedList (java.util.LinkedList)1 StringTokenizer (java.util.StringTokenizer)1 QName (javax.xml.namespace.QName)1 XMLEvent (javax.xml.stream.events.XMLEvent)1