use of org.xmldb.api.base.ResourceSet in project exist by eXist-db.
the class EvalTest method evalWithExternalVars.
@Test
public void evalWithExternalVars() throws XPathException, XMLDBException {
final String query = "let $value := 'world' return\n" + "\tutil:eval(xs:anyURI('/db/" + INVOKABLE_QUERY_FILENAME + "'), false(), (xs:QName('" + INVOKABLE_QUERY_EXTERNAL_VAR_NAME + "'), $value))";
final ResourceSet result = existEmbeddedServer.executeQuery(query);
final LocalXMLResource res = (LocalXMLResource) result.getResource(0);
final Node n = res.getContentAsDOM();
assertEquals(n.getLocalName(), "hello");
assertEquals("world", n.getFirstChild().getNodeValue());
}
use of org.xmldb.api.base.ResourceSet in project exist by eXist-db.
the class EvalTest method testEvalSupplyingContext.
@Test
public void testEvalSupplyingContext() throws XPathException, XMLDBException {
final String query = "let $xml := <test><a/></test>\n" + "let $context := <static-context>\n" + "<default-context>{$xml}</default-context>\n" + "</static-context>\n" + "let $query := 'count(.//*) 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);
}
use of org.xmldb.api.base.ResourceSet in project exist by eXist-db.
the class EvalTest method evalAndSerializeDefaultOptions.
@Test
public void evalAndSerializeDefaultOptions() throws XMLDBException {
String query = "let $query := \"<elem1>hello</elem1>\"\n" + "return\n" + "util:eval-and-serialize($query, map { \"method\": \"adaptive\" })";
ResourceSet result = existEmbeddedServer.executeQuery(query);
Resource r = result.getResource(0);
assertEquals("<elem1>hello</elem1>", r.getContent());
// test that XQuery Prolog output options override the default provided options
query = "xquery version \"3.1\";\n" + "declare namespace output = \"http://www.w3.org/2010/xslt-xquery-serialization\";\n" + "declare option output:method \"text\";\n" + "let $query := \"<elem1>hello</elem1>\"\n" + "return\n" + "util:eval-and-serialize($query, map { \"method\": \"adaptive\" })";
result = existEmbeddedServer.executeQuery(query);
r = result.getResource(0);
assertEquals("hello", r.getContent());
}
use of org.xmldb.api.base.ResourceSet in project exist by eXist-db.
the class JaxpDtdCatalogTest method executeAndEvaluate.
private void executeAndEvaluate(final String query, final String expectedValue) throws XMLDBException, SAXException, IOException, XpathException {
final ResourceSet results = existEmbeddedServer.executeQuery(query);
assertEquals(1, results.getSize());
final String r = (String) results.getResource(0).getContent();
assertXpathEvaluatesTo(expectedValue, "//status/text()", r);
}
use of org.xmldb.api.base.ResourceSet in project exist by eXist-db.
the class JaxpDtdCatalogTest method clearGrammarCache.
@Before
public void clearGrammarCache() throws XMLDBException {
final ResourceSet results = existEmbeddedServer.executeQuery("validation:clear-grammar-cache()");
results.getResource(0).getContent();
}
Aggregations