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 });
}
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());
}
Aggregations