Search in sources :

Example 21 with NodeReadTrx

use of org.sirix.api.NodeReadTrx in project sirix by sirixdb.

the class TestNodeWrapperXPath method testDefaultNamespaceTextAll.

@SuppressWarnings("unchecked")
@Test
public void testDefaultNamespaceTextAll() throws Exception {
    xpe.setNamespaceContext(new DocNamespaceContext());
    final XPathExpression findLine = xpe.compile("//p:a/text()");
    final NodeInfo doc = new DocumentWrapper(mHolder.getSession(), config);
    // Execute XPath.
    final ArrayList<NodeWrapper> result = (ArrayList<NodeWrapper>) findLine.evaluate(doc, XPathConstants.NODESET);
    assertNotNull(result);
    final NodeReadTrx rtx = mHolder.getSession().beginNodeReadTrx();
    rtx.moveTo(result.get(0).getKey());
    assertEquals("oops1", rtx.getValue());
    rtx.moveTo(result.get(1).getKey());
    assertEquals("oops2", rtx.getValue());
    rtx.moveTo(result.get(2).getKey());
    assertEquals("oops3", rtx.getValue());
    rtx.close();
}
Also used : XPathExpression(javax.xml.xpath.XPathExpression) NodeReadTrx(org.sirix.api.NodeReadTrx) NodeInfo(net.sf.saxon.om.NodeInfo) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Aggregations

NodeReadTrx (org.sirix.api.NodeReadTrx)21 SirixException (org.sirix.exception.SirixException)13 IOException (java.io.IOException)6 SessionConfiguration (org.sirix.access.conf.SessionConfiguration)6 Database (org.sirix.api.Database)6 Session (org.sirix.api.Session)6 WebApplicationException (javax.ws.rs.WebApplicationException)4 Axis (org.sirix.api.Axis)4 XMLStreamException (javax.xml.stream.XMLStreamException)3 NodeInfo (net.sf.saxon.om.NodeInfo)3 JaxRxException (org.jaxrx.core.JaxRxException)3 Test (org.junit.Test)3 DescendantAxis (org.sirix.axis.DescendantAxis)3 XPathAxis (org.sirix.service.xml.xpath.XPathAxis)3 ArrayList (java.util.ArrayList)2 XPathExpression (javax.xml.xpath.XPathExpression)2 QNm (org.brackit.xquery.atomic.QNm)2 FilterAxis (org.sirix.axis.filter.FilterAxis)2 TextFilter (org.sirix.axis.filter.TextFilter)2 TransactionTuple (org.sirix.gui.view.TransactionTuple)2