Search in sources :

Example 16 with ResourceSet

use of org.xmldb.api.base.ResourceSet in project exist by eXist-db.

the class GetRunningXQueriesTest method caller.

@Test
public void caller() throws XMLDBException, XpathException, IOException, SAXException {
    final ResourceSet result = existXmldbEmbeddedServer.executeQuery("system:get-running-xqueries()");
    assertNotNull(result);
    final String resultDoc = (String) result.getResource(0).getContent();
    assertXpathEvaluatesTo("1", "count(//@caller)", resultDoc);
}
Also used : ResourceSet(org.xmldb.api.base.ResourceSet) Test(org.junit.Test)

Example 17 with ResourceSet

use of org.xmldb.api.base.ResourceSet in project exist by eXist-db.

the class Base64FunctionsTest method testBase64DecodeUrlSafe.

@Test
public void testBase64DecodeUrlSafe() throws XMLDBException {
    final String query = "util:base64-decode( 'LsO_ZA' )";
    final ResourceSet result = existXmldbEmbeddedServer.executeQuery(query);
    final String r = (String) result.getResource(0).getContent();
    assertEquals(".ÿd", r);
}
Also used : ResourceSet(org.xmldb.api.base.ResourceSet) Test(org.junit.Test)

Example 18 with ResourceSet

use of org.xmldb.api.base.ResourceSet in project exist by eXist-db.

the class EvalTest method evalwithPI.

@Test
public void evalwithPI() throws XPathException, XMLDBException {
    final String query = "let $query := 'let $a := <test><?pi test?></test> return count($a//processing-instruction())'\n" + "return\n" + "util:eval($query)";
    final ResourceSet result = existEmbeddedServer.executeQuery(query);
    final String r = (String) result.getResource(0).getContent();
    assertEquals("1", r);
}
Also used : ResourceSet(org.xmldb.api.base.ResourceSet)

Example 19 with ResourceSet

use of org.xmldb.api.base.ResourceSet in project exist by eXist-db.

the class EvalTest method evalAndSerializeSubsequence.

@Test
public void evalAndSerializeSubsequence() throws XMLDBException {
    final String query = "let $query := \"for $i in (1 to 10) return <i>{$i}</i>\"\n" + "return\n" + "util:eval-and-serialize($query, (), 1, 4)";
    final ResourceSet result = existEmbeddedServer.executeQuery(query);
    final Resource r = result.getResource(0);
    assertEquals("<i>1</i><i>2</i><i>3</i><i>4</i>", r.getContent());
}
Also used : BinaryResource(org.xmldb.api.modules.BinaryResource) Resource(org.xmldb.api.base.Resource) ResourceSet(org.xmldb.api.base.ResourceSet)

Example 20 with ResourceSet

use of org.xmldb.api.base.ResourceSet in project exist by eXist-db.

the class EvalTest method testEvalWithContextVariable.

@Test
public void testEvalWithContextVariable() throws XPathException, XMLDBException {
    final String query = "let $xml := <test><a/><b/></test>\n" + "let $context := <static-context>\n" + "<variable name='xml'>{$xml}</variable>\n" + "</static-context>\n" + "let $query := 'count($xml//*) mod 2 = 0'\n" + "return\n" + "util:eval-with-context($query, $context, false())";
    final ResourceSet result = existEmbeddedServer.executeQuery(query);
    final String r = (String) result.getResource(0).getContent();
    assertEquals("true", r);
}
Also used : ResourceSet(org.xmldb.api.base.ResourceSet)

Aggregations

ResourceSet (org.xmldb.api.base.ResourceSet)383 XPathQueryService (org.xmldb.api.modules.XPathQueryService)123 Test (org.junit.Test)117 EXistXPathQueryService (org.exist.xmldb.EXistXPathQueryService)100 XMLResource (org.xmldb.api.modules.XMLResource)80 Collection (org.xmldb.api.base.Collection)55 Resource (org.xmldb.api.base.Resource)45 XQueryService (org.xmldb.api.modules.XQueryService)29 XMLDBException (org.xmldb.api.base.XMLDBException)23 EXistResource (org.exist.xmldb.EXistResource)20 BinaryResource (org.xmldb.api.modules.BinaryResource)17 CollectionManagementService (org.xmldb.api.modules.CollectionManagementService)14 Node (org.w3c.dom.Node)11 IndexQueryService (org.exist.xmldb.IndexQueryService)9 Diff (org.xmlunit.diff.Diff)9 EXistCollectionManagementService (org.exist.xmldb.EXistCollectionManagementService)8 UserManagementService (org.exist.xmldb.UserManagementService)8 Source (javax.xml.transform.Source)7 ResourceIterator (org.xmldb.api.base.ResourceIterator)7 XUpdateQueryService (org.xmldb.api.modules.XUpdateQueryService)6