Search in sources :

Example 41 with XPathAxis

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

the class FileSystemWatcher method findNode.

/**
 * Find node corresponding to the path. The {@link XdmNodeWriteTrx} globally used is moved to the
 * found node.
 *
 * @param query xpath expression
 * @throws SirixXPathException if expression isn't valid
 * @throws NullPointerException if {@code pXPath} is {@code null}
 */
private void findNode(final String query) throws SirixXPathException {
    final Axis axis = new XPathAxis(mWtx, checkNotNull(query));
    int countResults = 0;
    long resultNodeKey = Fixed.NULL_NODE_KEY.getStandardProperty();
    while (axis.hasNext()) {
        resultNodeKey = axis.next();
        countResults++;
        assert countResults == 1 : "At maximum one item should be found!";
    }
    mWtx.moveTo(resultNodeKey);
}
Also used : XPathAxis(org.sirix.service.xml.xpath.XPathAxis) Axis(org.sirix.api.Axis) XPathAxis(org.sirix.service.xml.xpath.XPathAxis)

Example 42 with XPathAxis

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

the class FunctionsXMarkTest method testDistinctValues.

/**
 * Test function distinct-values().
 *
 * @throws SirixXPathException
 */
@Ignore
@Test
public final void testDistinctValues() throws SirixXPathException {
    final String query = "fn:distinct-values(/site/open_auctions/open_auction/bidder[personref[@person=\"person2436\"]]/increase)";
    final String result = "12.00";
    XPathStringChecker.testIAxisConventions(new XPathAxis(holder.getReader(), query), new String[] { result });
}
Also used : XPathAxis(org.sirix.service.xml.xpath.XPathAxis) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 43 with XPathAxis

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

the class FunctionsXMarkTest method testId.

/**
 * Test function id().
 *
 * @throws SirixXPathException
 */
@Ignore
@Test
public final void testId() throws SirixXPathException {
    final String query = "fn:id(/site/people/person[@id=\"person1\"]/watches/watch/@open_auction)";
    final String result = "";
    XPathStringChecker.testIAxisConventions(new XPathAxis(holder.getReader(), query), new String[] { result });
}
Also used : XPathAxis(org.sirix.service.xml.xpath.XPathAxis) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 44 with XPathAxis

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

the class FunctionsXMarkTest method testPosition.

/**
 * Test function position().
 *
 * @throws SirixXPathException
 */
@Ignore
@Test
public final void testPosition() throws SirixXPathException {
    final String query = "/site/open_auctions/open_auction/bidder/increase[position()=1]";
    final String result = "<increase>10.50</increase>";
    XPathStringChecker.testIAxisConventions(new XPathAxis(holder.getReader(), query), new String[] { result });
}
Also used : XPathAxis(org.sirix.service.xml.xpath.XPathAxis) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 45 with XPathAxis

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

the class FunctionsXMarkTest method testString.

/**
 * Test function string().
 *
 * @throws SirixXPathException
 */
@Ignore
@Test
public final void testString() throws SirixXPathException {
    final String query = "fn:string(/site/people/person[@id=\"person3\"]/name)";
    final String result = "Limor Simone";
    XPathStringChecker.testIAxisConventions(new XPathAxis(holder.getReader(), query), new String[] { result });
}
Also used : XPathAxis(org.sirix.service.xml.xpath.XPathAxis) Ignore(org.junit.Ignore) 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