use of org.xmldb.api.modules.XQueryService in project exist by eXist-db.
the class DuplicateAttributesTest method appendConstrAttr.
/**
* Add constructed in-memory attribute to element which already has an
* attribute of that name.
*/
@Test(expected = XMLDBException.class)
public void appendConstrAttr() throws XMLDBException {
XQueryService xqs = (XQueryService) testCollection.getService("XQueryService", "1.0");
String query = "let $a := <root attr=\"ab\"/>" + "let $b := \n" + " <node attr=\"a\" b=\"c\">{$a//@attr}</node>" + "return $a";
xqs.query(query);
}
use of org.xmldb.api.modules.XQueryService in project exist by eXist-db.
the class DuplicateAttributesTest method appendStoredAttrOK.
/**
* Add attribute to element which has no conflicting attributes.
*/
@Test
public void appendStoredAttrOK() {
try {
XQueryService xqs = (XQueryService) testCollection.getService("XQueryService", "1.0");
String query = "let $a := \n" + "<node attr=\"a\" b=\"c\">{doc(\"/db/test/stored2.xml\")//@attr2}</node>" + "return $a";
ResourceSet result = xqs.query(query);
assertEquals(1, result.getSize());
assertEquals("<node attr=\"a\" b=\"c\" attr2=\"ab\"/>", result.getResource(0).getContent());
} catch (XMLDBException e) {
LOG.error(e.getMessage(), e);
fail(e.getMessage());
}
}
use of org.xmldb.api.modules.XQueryService in project exist by eXist-db.
the class EntitiesTest method uriConstructor.
@Test
public void uriConstructor() throws XMLDBException {
XQueryService service = getQueryService();
ResourceSet result;
result = queryAndAssert(service, "xs:anyURI(\"index.xql?a=1&b=2\")", 1, null);
// TODO: could check result
result = queryAndAssert(service, "xs:anyURI('a') le xs:anyURI('b')", 1, null);
assertEquals("true", result.getResource(0).getContent());
}
use of org.xmldb.api.modules.XQueryService in project exist by eXist-db.
the class EntitiesTest method storeXMLStringAndGetQueryService.
/**
* stores XML String and get Query Service
* @param documentName to be stored in the DB
* @param content to be stored in the DB
* @return the XQuery Service
* @throws XMLDBException
*/
@SuppressWarnings("unused")
private XQueryService storeXMLStringAndGetQueryService(String documentName, String content) throws XMLDBException {
XMLResource doc = (XMLResource) testCollection.createResource(documentName, "XMLResource");
doc.setContent(content);
testCollection.storeResource(doc);
XQueryService service = (XQueryService) testCollection.getService("XPathQueryService", "1.0");
return service;
}
use of org.xmldb.api.modules.XQueryService in project exist by eXist-db.
the class EntitiesTest method stringConstructor.
@Test
public void stringConstructor() throws XMLDBException {
XQueryService service = getQueryService();
@SuppressWarnings("unused") ResourceSet result;
result = queryAndAssert(service, "'&'", 1, null);
result = queryAndAssert(service, "'<'", 1, null);
result = queryAndAssert(service, "'>'", 1, null);
result = queryAndAssert(service, "'''", 1, null);
result = queryAndAssert(service, "'"'", 1, null);
// TODO: could check result
}
Aggregations