Search in sources :

Example 36 with XPathQueryService

use of org.xmldb.api.modules.XPathQueryService in project exist by eXist-db.

the class XQueryTest method predicateInPredicateEmptyResult_1828168.

/**
 * @see http://sourceforge.net/support/tracker.php?aid=1828168
 */
@Test
public void predicateInPredicateEmptyResult_1828168() throws XMLDBException {
    String query = "let $docs := <Document/> return $docs[a[1] = 'b']";
    XPathQueryService service = (XPathQueryService) getTestCollection().getService("XPathQueryService", "1.0");
    ResourceSet result = service.query(query);
    assertEquals(0, result.getSize());
    query = "<a/>[() = 'b']";
    service = (XPathQueryService) getTestCollection().getService("XPathQueryService", "1.0");
    result = service.query(query);
    assertEquals(0, result.getSize());
}
Also used : XPathQueryService(org.xmldb.api.modules.XPathQueryService) EXistXPathQueryService(org.exist.xmldb.EXistXPathQueryService) ResourceSet(org.xmldb.api.base.ResourceSet)

Example 37 with XPathQueryService

use of org.xmldb.api.modules.XPathQueryService in project exist by eXist-db.

the class XQueryTest method attributeNamespaceDeclaration_1848497.

/**
 * @see http://sourceforge.net/support/tracker.php?aid=1848497
 */
@Ignore
@Test
public void attributeNamespaceDeclaration_1848497() throws XMLDBException {
    String query = "declare namespace foo = \"foo\";" + "declare function foo:boe() { \"boe\" };" + "<xml xmlns:foo2=\"foo\">{ foo2:boe() }</xml>";
    XPathQueryService service = (XPathQueryService) getTestCollection().getService("XPathQueryService", "1.0");
    ResourceSet result = service.query(query);
    assertEquals(1, result.getSize());
    assertEquals(query, "<xml xmlns:foo2=\"foo\">boe</xml>", result.getResource(0).getContent().toString());
}
Also used : XPathQueryService(org.xmldb.api.modules.XPathQueryService) EXistXPathQueryService(org.exist.xmldb.EXistXPathQueryService) ResourceSet(org.xmldb.api.base.ResourceSet)

Example 38 with XPathQueryService

use of org.xmldb.api.modules.XPathQueryService in project exist by eXist-db.

the class XQueryTest method attribute_1691174.

/**
 * @see http://sourceforge.net/tracker/index.php?func=detail&aid=1691174&group_id=17691&atid=117691
 */
@Test
public void attribute_1691174() throws XMLDBException {
    String query = "declare function local:show($el1, $el2) { " + "	<Foobar> " + "	{ (\"first: \", $el1, \" second: \", $el2) } " + "	</Foobar> " + "}; " + "declare function local:attrib($n as node()) { " + "	<Attrib>{$n}</Attrib> " + "}; " + "local:show( " + "	<Attrib name=\"value\"/>, " + "	local:attrib(attribute name {\"value\"})  (: Exist bug! :) " + ")  ";
    XPathQueryService service = (XPathQueryService) getTestCollection().getService("XPathQueryService", "1.0");
    ResourceSet result = service.query(query);
    assertEquals("XQuery: " + query, 1, result.getSize());
}
Also used : XPathQueryService(org.xmldb.api.modules.XPathQueryService) EXistXPathQueryService(org.exist.xmldb.EXistXPathQueryService) ResourceSet(org.xmldb.api.base.ResourceSet)

Example 39 with XPathQueryService

use of org.xmldb.api.modules.XPathQueryService in project exist by eXist-db.

the class XQueryTest method resolveBaseURI_1841635.

/**
 * @see http://sourceforge.net/support/tracker.php?aid=1841635
 */
@Test
public void resolveBaseURI_1841635() throws XMLDBException {
    String xmldoc = "<Root><Node1><Node2><Node3></Node3></Node2></Node1></Root>";
    XPathQueryService service = storeXMLStringAndGetQueryService("baseuri.xml", xmldoc);
    String query = "doc('/db/test/baseuri.xml')/Root/Node1/base-uri()";
    ResourceSet result = service.query(query);
    assertEquals(1, result.getSize());
    assertEquals("/db/test/baseuri.xml", result.getResource(0).getContent().toString());
    query = "doc('/db/test/baseuri.xml')/Root/Node1/base-uri()";
    result = service.query(query);
    assertEquals(1, result.getSize());
    assertEquals("/db/test/baseuri.xml", result.getResource(0).getContent().toString());
    query = "doc('/db/test/baseuri.xml')/Root/Node1/Node2/base-uri()";
    result = service.query(query);
    assertEquals(1, result.getSize());
    assertEquals("/db/test/baseuri.xml", result.getResource(0).getContent().toString());
    query = "doc('/db/test/baseuri.xml')/Root/Node1/Node2/Node3/base-uri()";
    result = service.query(query);
    assertEquals(1, result.getSize());
    assertEquals("/db/test/baseuri.xml", result.getResource(0).getContent().toString());
}
Also used : XPathQueryService(org.xmldb.api.modules.XPathQueryService) EXistXPathQueryService(org.exist.xmldb.EXistXPathQueryService) ResourceSet(org.xmldb.api.base.ResourceSet)

Example 40 with XPathQueryService

use of org.xmldb.api.modules.XPathQueryService in project exist by eXist-db.

the class XQueryTest method largeAttributeContains.

@Test
public void largeAttributeContains() throws XMLDBException {
    ResourceSet result;
    String query;
    @SuppressWarnings("unused") XMLResource resu;
    @SuppressWarnings("unused") String large = createXMLContentWithLargeString();
    XPathQueryService service = storeXMLStringAndGetQueryService(file_name, xml);
    query = "doc('" + file_name + "') / details/metadata[ contains(@docid, 'aa') ]";
    result = service.queryResource(file_name, query);
    assertEquals("XQuery: " + query, nbElem, result.getSize());
}
Also used : XPathQueryService(org.xmldb.api.modules.XPathQueryService) EXistXPathQueryService(org.exist.xmldb.EXistXPathQueryService) ResourceSet(org.xmldb.api.base.ResourceSet) XMLResource(org.xmldb.api.modules.XMLResource)

Aggregations

XPathQueryService (org.xmldb.api.modules.XPathQueryService)148 ResourceSet (org.xmldb.api.base.ResourceSet)123 EXistXPathQueryService (org.exist.xmldb.EXistXPathQueryService)92 XMLResource (org.xmldb.api.modules.XMLResource)60 Collection (org.xmldb.api.base.Collection)31 Test (org.junit.Test)22 Resource (org.xmldb.api.base.Resource)18 XMLDBException (org.xmldb.api.base.XMLDBException)14 EXistResource (org.exist.xmldb.EXistResource)10 CollectionManagementService (org.xmldb.api.modules.CollectionManagementService)9 XUpdateQueryService (org.xmldb.api.modules.XUpdateQueryService)8 IndexQueryService (org.exist.xmldb.IndexQueryService)6 IOException (java.io.IOException)3 ResourceIterator (org.xmldb.api.base.ResourceIterator)3 BinaryResource (org.xmldb.api.modules.BinaryResource)3 MalformedURLException (java.net.MalformedURLException)2 Path (java.nio.file.Path)2 Node (org.w3c.dom.Node)2 HttpURLConnection (java.net.HttpURLConnection)1 URL (java.net.URL)1