use of org.sirix.service.xml.xpath.XPathAxis in project sirix by sirixdb.
the class ForAxisTest method testFor.
@Test
public void testFor() throws SirixException {
final XdmNodeReadTrx rtx = holder.getReader();
rtx.moveTo(1L);
AbsAxisTest.testIAxisConventions(new XPathAxis(rtx, "for $a in child::text() return child::node()"), new long[] { 4L, 5L, 8L, 9L, 13L, 4L, 5L, 8L, 9L, 13L, 4L, 5L, 8L, 9L, 13L });
AbsAxisTest.testIAxisConventions(new XPathAxis(rtx, "for $a in child::node() return $a/node()"), new long[] { 6L, 7L, 11L, 12L });
AbsAxisTest.testIAxisConventions(new XPathAxis(rtx, "for $a in child::node() return $a/text()"), new long[] { 6L, 12L });
AbsAxisTest.testIAxisConventions(new XPathAxis(rtx, "for $a in child::node() return $a/c"), new long[] { 7L, 11L });
// IAxisTest.testIAxisConventions(new XPathAxis(
// rtx,
// "for $a in child::node(), $b in /node(), $c in ., $d in /c return $a/c"),
// new long[] {7L, 11L});
AbsAxisTest.testIAxisConventions(new XPathAxis(rtx, "for $a in child::node() return $a[@p:x]"), new long[] { 9L });
AbsAxisTest.testIAxisConventions(new XPathAxis(rtx, "for $a in . return $a"), new long[] { 1L });
final AbstractAxis axis = new XPathAxis(rtx, "for $i in (10, 20), $j in (1, 2) return ($i + $j)");
assertEquals(true, axis.hasNext());
axis.next();
assertEquals("11.0", rtx.getValue());
assertEquals(true, axis.hasNext());
axis.next();
assertEquals("12.0", rtx.getValue());
assertEquals(true, axis.hasNext());
axis.next();
assertEquals("21.0", rtx.getValue());
assertEquals(true, axis.hasNext());
axis.next();
assertEquals("22.0", rtx.getValue());
assertEquals(false, axis.hasNext());
}
use of org.sirix.service.xml.xpath.XPathAxis in project sirix by sirixdb.
the class ConXPathAxisTest method testCount.
@Test
public void testCount() throws IOException {
try {
holder.getReader().moveTo(1L);
XPathStringChecker.testIAxisConventions(new XPathAxis(holder.getReader(), "fn:count(//node())"), new String[] { "10" });
} catch (final SirixXPathException mExp) {
mExp.getStackTrace();
}
}
use of org.sirix.service.xml.xpath.XPathAxis in project sirix by sirixdb.
the class ConXPathAxisTest method testNodeTests.
@Test
public void testNodeTests() {
try {
// Find descendants starting from nodeKey 0L (root).
holder.getReader().moveToDocumentRoot();
AbsAxisTest.testIAxisConventions(new XPathAxis(holder.getReader(), "/p:a/node()"), new long[] { 4L, 5L, 8L, 9L, 13L });
AbsAxisTest.testIAxisConventions(new XPathAxis(holder.getReader(), "p:a/text()"), new long[] { 4L, 8L, 13L });
AbsAxisTest.testIAxisConventions(new XPathAxis(holder.getReader(), "/p:a/b/text()"), new long[] { 6L, 12L });
AbsAxisTest.testIAxisConventions(new XPathAxis(holder.getReader(), "p:a/b/node()"), new long[] { 6L, 7L, 11L, 12L });
} catch (final SirixXPathException mExp) {
mExp.getStackTrace();
}
}
use of org.sirix.service.xml.xpath.XPathAxis in project sirix by sirixdb.
the class ConcurrentAxisTest method testSeriellOld.
/**
* Test seriell.
*/
// @Ignore
// @SkipBench
// @Bench
@Test
public void testSeriellOld() throws Exception {
// final String query = "//people/person[@id=\"person3\"]/name";
// final String query = "count(//location[text() = \"United States\"])";
final String query = "//regions/africa//location";
// final String result = "<name>Limor Simone</name>";
final int resultNumber = 55;
final Axis axis = new XPathAxis(holder.getReader(), query);
for (int i = 0; i < resultNumber; i++) {
assertEquals(true, axis.hasNext());
axis.next();
}
assertEquals(false, axis.hasNext());
}
use of org.sirix.service.xml.xpath.XPathAxis in project sirix by sirixdb.
the class InstanceOfExprTest method testInstanceOfExpr.
@Test(expected = NoSuchElementException.class)
public void testInstanceOfExpr() throws SirixException {
final AbstractAxis axis1 = new XPathAxis(holder.getReader(), "1 instance of xs:integer");
assertEquals(true, axis1.hasNext());
axis1.next();
assertEquals(holder.getReader().keyForName("xs:boolean"), holder.getReader().getTypeKey());
assertEquals(true, Boolean.parseBoolean(holder.getReader().getValue()));
assertEquals(false, axis1.hasNext());
final AbstractAxis axis2 = new XPathAxis(holder.getReader(), "\"hallo\" instance of xs:integer");
assertEquals(true, axis2.hasNext());
axis2.next();
assertEquals(holder.getReader().keyForName("xs:boolean"), holder.getReader().getTypeKey());
assertEquals(false, Boolean.parseBoolean(holder.getReader().getValue()));
assertEquals(false, axis2.hasNext());
final AbstractAxis axis3 = new XPathAxis(holder.getReader(), "\"hallo\" instance of xs:string ?");
assertEquals(true, axis3.hasNext());
axis3.next();
assertEquals(holder.getReader().keyForName("xs:boolean"), holder.getReader().getTypeKey());
assertEquals(true, Boolean.parseBoolean(holder.getReader().getValue()));
assertEquals(false, axis3.hasNext());
final AbstractAxis axis4 = new XPathAxis(holder.getReader(), "\"hallo\" instance of xs:string +");
assertEquals(true, axis4.hasNext());
axis4.next();
assertEquals(holder.getReader().keyForName("xs:boolean"), holder.getReader().getTypeKey());
assertEquals(true, Boolean.parseBoolean(holder.getReader().getValue()));
assertEquals(false, axis4.hasNext());
final AbstractAxis axis5 = new XPathAxis(holder.getReader(), "\"hallo\" instance of xs:string *");
assertEquals(true, axis5.hasNext());
axis5.next();
assertEquals(holder.getReader().keyForName("xs:boolean"), holder.getReader().getTypeKey());
assertEquals(true, Boolean.parseBoolean(holder.getReader().getValue()));
assertEquals(false, axis5.hasNext());
axis5.next();
}
Aggregations