Search in sources :

Example 31 with XPathAxis

use of org.sirix.service.xml.xpath.XPathAxis 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 32 with XPathAxis

use of org.sirix.service.xml.xpath.XPathAxis 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)

Example 33 with XPathAxis

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

the class ConXPathAxisTest method testDescendant.

@Test
public void testDescendant() {
    try {
        // Find descendants starting from nodeKey 0L (root).
        holder.getReader().moveToDocumentRoot();
        AbsAxisTest.testIAxisConventions(new XPathAxis(holder.getReader(), "/p:a//b"), new long[] { 5L, 9L });
        AbsAxisTest.testIAxisConventions(new XPathAxis(holder.getReader(), "//p:a"), new long[] { 1L });
        AbsAxisTest.testIAxisConventions(new XPathAxis(holder.getReader(), "descendant-or-self::p:a"), new long[] { 1L });
        AbsAxisTest.testIAxisConventions(new XPathAxis(holder.getReader(), "/p:a/descendant-or-self::b"), new long[] { 5L, 9L });
        AbsAxisTest.testIAxisConventions(new XPathAxis(holder.getReader(), "p:a/descendant::b"), new long[] { 5L, 9L });
        AbsAxisTest.testIAxisConventions(new XPathAxis(holder.getReader(), "p:a/descendant::p:a"), new long[] {});
    } 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 34 with XPathAxis

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

the class ConXPathAxisTest method testDupElemination.

// 
@Test
public void testDupElemination() {
    try {
        // Find descendants starting from nodeKey 0L (root).
        holder.getReader().moveTo(1L);
        AbsAxisTest.testIAxisConventions(new XPathAxis(holder.getReader(), "child::node()/parent::node()"), new long[] { 1L });
        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 35 with XPathAxis

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

the class ConXPathAxisTest method testSelf.

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