use of net.sf.saxon.om.NodeInfo in project sirix by sirixdb.
the class TestNodeWrapperXPath method testElementACount.
@Test
public void testElementACount() throws Exception {
final XPathExpression findLine = xpe.compile("count(//a)");
final NodeInfo doc = new DocumentWrapper(mHolder.getSession(), config);
// Execute XPath.
final double result = Double.parseDouble(findLine.evaluate(doc, XPathConstants.NUMBER).toString());
assertNotNull(result);
assertEquals(0D, result, 0D);
}
use of net.sf.saxon.om.NodeInfo in project sirix by sirixdb.
the class TestNodeWrapperXPath method testNamespaceAttributeCount.
@Test
public void testNamespaceAttributeCount() throws Exception {
xpe.setNamespaceContext(new DocNamespaceContext());
final XPathExpression findLine = xpe.compile("count(//p:a/@p:i)");
final NodeInfo doc = new DocumentWrapper(mHolder.getSession(), config);
// Execute XPath.
final double result = Double.parseDouble(findLine.evaluate(doc, XPathConstants.NUMBER).toString());
assertNotNull(result);
assertEquals(0D, result, 0D);
}
use of net.sf.saxon.om.NodeInfo in project sirix by sirixdb.
the class TestNodeWrapperXPath method testDefaultNamespaceText1.
@Test
public void testDefaultNamespaceText1() throws Exception {
xpe.setNamespaceContext(new DocNamespaceContext());
final XPathExpression findLine = xpe.compile("//p:a/text()[1]");
final NodeInfo doc = new DocumentWrapper(mHolder.getSession(), config);
// Execute XPath.
final String result = (String) findLine.evaluate(doc, XPathConstants.STRING);
assertNotNull(result);
assertEquals("oops1", result);
}
use of net.sf.saxon.om.NodeInfo in project sirix by sirixdb.
the class TestNodeWrapperXPath method testBAll.
@SuppressWarnings("unchecked")
@Test
public void testBAll() throws Exception {
xpe.setNamespaceContext(new DocNamespaceContext());
final XPathExpression findLine = xpe.compile("//b");
final NodeInfo doc = new DocumentWrapper(mHolder.getSession(), config);
// Execute XPath.
final ArrayList<NodeWrapper> result = (ArrayList<NodeWrapper>) findLine.evaluate(doc, XPathConstants.NODESET);
assertNotNull(result);
assertEquals(5, result.get(0).getKey());
assertEquals(9, result.get(1).getKey());
final NodeReadTrx rtx = mHolder.getSession().beginNodeReadTrx();
rtx.moveTo(result.get(0).getKey());
assertEquals("b", rtx.getName().getLocalName());
rtx.moveTo(result.get(1).getKey());
assertEquals("b", rtx.getName().getLocalName());
}
use of net.sf.saxon.om.NodeInfo in project sirix by sirixdb.
the class TestNodeWrapperXPath method testB2.
@Test
public void testB2() throws Exception {
xpe.setNamespaceContext(new DocNamespaceContext());
final XPathExpression findLine = xpe.compile("//b[2]");
final NodeInfo doc = new DocumentWrapper(mHolder.getSession(), config);
// Execute XPath.
final String result = (String) findLine.evaluate(doc, XPathConstants.STRING);
assertNotNull(result);
assertEquals("bar", result);
}
Aggregations