Search in sources :

Example 6 with SirixXPathException

use of org.sirix.exception.SirixXPathException 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 7 with SirixXPathException

use of org.sirix.exception.SirixXPathException 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 8 with SirixXPathException

use of org.sirix.exception.SirixXPathException 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)

Example 9 with SirixXPathException

use of org.sirix.exception.SirixXPathException in project sirix by sirixdb.

the class ConXPathAxisTest method testAttributes.

@Test
public void testAttributes() {
    try {
        // Find descendants starting from nodeKey 0L (root).
        holder.getReader().moveToDocumentRoot();
        AbsAxisTest.testIAxisConventions(new XPathAxis(holder.getReader(), "/p:a[@i]"), new long[] { 1L });
        AbsAxisTest.testIAxisConventions(new XPathAxis(holder.getReader(), "/p:a/@i"), new long[] { 3L });
        AbsAxisTest.testIAxisConventions(new XPathAxis(holder.getReader(), "/p:a/@i/@*"), new long[] {});
        AbsAxisTest.testIAxisConventions(new XPathAxis(holder.getReader(), "p:a/b[@p:x]"), new long[] { 9L });
        XPathStringChecker.testIAxisConventions(new XPathAxis(holder.getReader(), "descendant-or-self::node()/@p:x = 'y'"), new String[] { "true" });
        AbsAxisTest.testIAxisConventions(new XPathAxis(holder.getReader(), "p:a[text()]"), new long[] { 1L });
        AbsAxisTest.testIAxisConventions(new XPathAxis(holder.getReader(), "p:a[element()]"), new long[] { 1L });
        AbsAxisTest.testIAxisConventions(new XPathAxis(holder.getReader(), "p:a[node()/text()]"), new long[] { 1L });
        AbsAxisTest.testIAxisConventions(new XPathAxis(holder.getReader(), "p:a[./node()]"), new long[] { 1L });
        AbsAxisTest.testIAxisConventions(new XPathAxis(holder.getReader(), "p:a[./node()/node()/node()]"), new long[] {});
        AbsAxisTest.testIAxisConventions(new XPathAxis(holder.getReader(), "p:a[//element()]"), new long[] { 1L });
        AbsAxisTest.testIAxisConventions(new XPathAxis(holder.getReader(), "p:a[/text()]"), new long[] {});
        AbsAxisTest.testIAxisConventions(new XPathAxis(holder.getReader(), "p:a[16<65]"), new long[] { 1L });
        AbsAxisTest.testIAxisConventions(new XPathAxis(holder.getReader(), "p:a[13>=4]"), new long[] { 1L });
        AbsAxisTest.testIAxisConventions(new XPathAxis(holder.getReader(), "p:a[13.0>=4]"), new long[] { 1L });
        AbsAxisTest.testIAxisConventions(new XPathAxis(holder.getReader(), "p:a[4 = 4]"), new long[] { 1L });
        AbsAxisTest.testIAxisConventions(new XPathAxis(holder.getReader(), "p:a[3=4]"), new long[] {});
        AbsAxisTest.testIAxisConventions(new XPathAxis(holder.getReader(), "p:a[3.2 = 3.22]"), new long[] {});
        AbsAxisTest.testIAxisConventions(new XPathAxis(holder.getReader(), "p:a[(3.2 + 0.02) = 3.22]"), new long[] { 1L });
        AbsAxisTest.testIAxisConventions(new XPathAxis(holder.getReader(), "p:a[@i = \"j\"]"), new long[] { 1L });
        AbsAxisTest.testIAxisConventions(new XPathAxis(holder.getReader(), "descendant-or-self::node()[@p:x = \"y\"]"), new long[] { 9L });
        // IAxisTest.testIAxisConventions(new XPathAxis(holder.getRtx(),
        // "p:a[@i eq \"j\"]"),
        // new long[] { 1L });
        AbsAxisTest.testIAxisConventions(new XPathAxis(holder.getReader(), "p:a[@i=\"k\"]"), new long[] {});
        AbsAxisTest.testIAxisConventions(new XPathAxis(holder.getReader(), "p:a/b[@p:x=\"y\"]"), new long[] { 9L });
    } 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 10 with SirixXPathException

use of org.sirix.exception.SirixXPathException in project sirix by sirixdb.

the class ConXPathAxisTest method testParent.

@Test
public void testParent() {
    try {
        // Find ancestor starting from nodeKey 8L.
        holder.getReader().moveTo(9L);
        AbsAxisTest.testIAxisConventions(new XPathAxis(holder.getReader(), "parent::p:a"), new long[] { 1L });
        holder.getReader().moveTo(11L);
        AbsAxisTest.testIAxisConventions(new XPathAxis(holder.getReader(), "parent::b"), new long[] { 9L });
        holder.getReader().moveTo(11L);
        AbsAxisTest.testIAxisConventions(new XPathAxis(holder.getReader(), "parent::node()"), new long[] { 9L });
        holder.getReader().moveTo(13L);
        AbsAxisTest.testIAxisConventions(new XPathAxis(holder.getReader(), "parent::node()"), new long[] { 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)

Aggregations

SirixXPathException (org.sirix.exception.SirixXPathException)16 Test (org.junit.Test)14 AbsAxisTest (org.sirix.axis.AbsAxisTest)12 XPathAxis (org.sirix.service.xml.xpath.XPathAxis)12 AtomicValue (org.sirix.service.xml.xpath.AtomicValue)3 LiteralExpr (org.sirix.service.xml.xpath.expr.LiteralExpr)2 Axis (org.sirix.api.Axis)1 DescendantAxis (org.sirix.axis.DescendantAxis)1 AbstractAxis (org.sirix.service.xml.xpath.AbstractAxis)1 SequenceAxis (org.sirix.service.xml.xpath.expr.SequenceAxis)1