Search in sources :

Example 66 with XPathAxis

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

the class UnionAxisTest method testUnion.

@Test
public void testUnion() throws SirixException {
    holder.getReader().moveTo(1L);
    AbsAxisTest.testIAxisConventions(new XPathAxis(holder.getReader(), "child::node()/parent::node() union child::node()"), new long[] { 1L, 4L, 5L, 8L, 9L, 13L });
    AbsAxisTest.testIAxisConventions(new XPathAxis(holder.getReader(), "child::node()/parent::node() | child::node()"), new long[] { 1L, 4L, 5L, 8L, 9L, 13L });
    AbsAxisTest.testIAxisConventions(new XPathAxis(holder.getReader(), "child::node()/parent::node() | child::node() | self::node()"), new long[] { 1L, 4L, 5L, 8L, 9L, 13L });
    AbsAxisTest.testIAxisConventions(new XPathAxis(holder.getReader(), "child::node()/parent::node() | child::node() | self::node()" + "union parent::node()"), new long[] { 1L, 4L, 5L, 8L, 9L, 13L, 0L });
    AbsAxisTest.testIAxisConventions(new XPathAxis(holder.getReader(), "b/preceding::node() union text() | descendant::node()"), new long[] { 4L, 8L, 7L, 6L, 5L, 13L, 9L, 11L, 12L });
    AbsAxisTest.testIAxisConventions(new XPathAxis(holder.getReader(), "//c/ancestor::node() | //node()"), new long[] { 5L, 1L, 9L, 4L, 8L, 13L, 6L, 7L, 11L, 12L });
}
Also used : XPathAxis(org.sirix.service.xml.xpath.XPathAxis) Test(org.junit.Test) AbsAxisTest(org.sirix.axis.AbsAxisTest)

Example 67 with XPathAxis

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

the class XPathParserTest method testLiterals.

@Test
public void testLiterals() throws SirixException {
    holder.getReader().moveTo(2L);
    AbstractAxis axis;
    axis = new XPathAxis(holder.getReader(), "\"12.5\"");
    assertEquals(true, axis.hasNext());
    axis.next();
    assertEquals("12.5", holder.getReader().getValue());
    assertEquals(holder.getReader().keyForName("xs:string"), holder.getReader().getTypeKey());
    assertEquals(false, axis.hasNext());
    axis = new XPathAxis(holder.getReader(), "\"He said, \"\"I don't like it\"\"\"");
    assertEquals(true, axis.hasNext());
    axis.next();
    assertEquals("He said, I don't like it", holder.getReader().getValue());
    assertEquals(holder.getReader().keyForName("xs:string"), holder.getReader().getTypeKey());
    assertEquals(false, axis.hasNext());
    axis = new XPathAxis(holder.getReader(), "12");
    assertEquals(true, axis.hasNext());
    axis.next();
    assertEquals(holder.getReader().keyForName("xs:integer"), holder.getReader().getTypeKey());
    assertEquals("12", holder.getReader().getValue());
    assertEquals(false, axis.hasNext());
    axis = new XPathAxis(holder.getReader(), "12.5");
    assertEquals(true, axis.hasNext());
    axis.next();
    assertEquals(holder.getReader().keyForName("xs:decimal"), holder.getReader().getTypeKey());
    assertEquals("12.5", holder.getReader().getValue());
    assertEquals(false, axis.hasNext());
    axis = new XPathAxis(holder.getReader(), "12.5E2");
    assertEquals(true, axis.hasNext());
    axis.next();
    assertEquals(holder.getReader().keyForName("xs:double"), holder.getReader().getTypeKey());
    assertEquals("12.5E2", holder.getReader().getValue());
    assertEquals(false, axis.hasNext());
    axis = new XPathAxis(holder.getReader(), "1");
    assertEquals(true, axis.hasNext());
    axis.next();
    assertEquals("1", holder.getReader().getValue());
    assertEquals(holder.getReader().keyForName("xs:integer"), holder.getReader().getTypeKey());
    assertEquals(false, axis.hasNext());
}
Also used : XPathAxis(org.sirix.service.xml.xpath.XPathAxis) AbstractAxis(org.sirix.service.xml.xpath.AbstractAxis) Test(org.junit.Test)

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