use of org.xmldb.api.modules.XPathQueryService in project exist by eXist-db.
the class XQueryTest method nameConflicts.
@Test
public void nameConflicts() throws XMLDBException {
String query = "let $a := <name name=\"Test\"/> return <wrap>{$a//@name}</wrap>";
XPathQueryService service = (XPathQueryService) getTestCollection().getService("XPathQueryService", "1.0");
ResourceSet result = service.query(query);
assertEquals(1, result.getSize());
assertEquals("<wrap name=\"Test\"/>", result.getResource(0).getContent().toString());
}
use of org.xmldb.api.modules.XPathQueryService in project exist by eXist-db.
the class XQueryTest method positionInPredicate.
@Test
public void positionInPredicate() throws XMLDBException {
String query = "let $example := <Root> <Element>1</Element> <Element>2</Element> </Root>" + "return $example/Element[1] ";
XPathQueryService service = (XPathQueryService) getTestCollection().getService("XPathQueryService", "1.0");
ResourceSet result = service.query(query);
assertEquals("<Element>1</Element>", result.getResource(0).getContent().toString());
query = "let $example := <Root> <Element>1</Element> <Element>2</Element> </Root>" + "return $example/Element[position() = 1] ";
result = service.query(query);
assertEquals("<Element>1</Element>", result.getResource(0).getContent().toString());
}
use of org.xmldb.api.modules.XPathQueryService in project exist by eXist-db.
the class XQueryTest method cardinalityAttributeNamespace_1884360.
/**
* @see http://sourceforge.net/support/tracker.php?aid=1884360
*/
@Test
public void cardinalityAttributeNamespace_1884360() throws XMLDBException {
String query = "let $el := <element a=\"1\" b=\"2\"/> " + "for $attr in $el/attribute()[namespace-uri(.) ne \"h\"] " + "return <c>{$attr}</c>";
XPathQueryService service = (XPathQueryService) getTestCollection().getService("XPathQueryService", "1.0");
ResourceSet result = service.query(query);
assertEquals(2, result.getSize());
assertEquals(query, "<c a=\"1\"/>", result.getResource(0).getContent().toString());
assertEquals(query, "<c b=\"2\"/>", result.getResource(1).getContent().toString());
}
use of org.xmldb.api.modules.XPathQueryService in project exist by eXist-db.
the class XQueryTest method elementConstructionWithNamespace_1740880.
/**
* @see http://sourceforge.net/support/tracker.php?aid=1740880
*/
@Test
public void elementConstructionWithNamespace_1740880() throws XMLDBException {
String query = "let $a := <foo:Bar xmlns:foo=\"urn:foo\"/> " + "let $b := element { QName(\"urn:foo\", \"foo:Bar\") } { () } " + "return deep-equal($a, $b) ";
XPathQueryService service = (XPathQueryService) getTestCollection().getService("XPathQueryService", "1.0");
ResourceSet result = service.query(query);
assertEquals("Oops", "true", result.getResource(0).getContent().toString());
}
use of org.xmldb.api.modules.XPathQueryService in project exist by eXist-db.
the class XQueryTest method largeAttributeText.
@Test
public void largeAttributeText() throws XMLDBException {
final String large = "challengesininformationretrievalandlanguagemodelingreportofaworkshopheldatthecenterforintelligentinformationretrievaluniversityofmassachusettsamherstseptember2002-extdocid-howardturtlemarksandersonnorbertfuhralansmeatonjayaslamdragomirradevwesselkraaijellenvoorheesamitsinghaldonnaharmanjaypontejamiecallannicholasbelkinjohnlaffertylizliddyronirosenfeldvictorlavrenkodavidjharperrichschwartzjohnpragerchengxiangzhaijinxixusalimroukosstephenrobertsonandrewmccallumbrucecroftrmanmathasuedumaisdjoerdhiemstraeduardhovyralphweischedelthomashofmannjamesallanchrisbuckleyphilipresnikdavidlewis2003";
String xml = "<details format='xml'><metadata docid='" + large + "'></metadata></details>";
final String FILE_NAME = "detail_xml.xml";
XPathQueryService service = storeXMLStringAndGetQueryService(FILE_NAME, xml);
String query = "doc('" + FILE_NAME + "') / details/metadata[@docid= '" + large + "' ]";
ResourceSet result = service.queryResource(FILE_NAME, query);
assertEquals(1, result.getSize());
xml = "<details format='xml'><metadata><docid>" + large + "</docid></metadata></details>";
service = storeXMLStringAndGetQueryService(FILE_NAME, xml);
query = "doc('" + FILE_NAME + "') / details/metadata[ docid= '" + large + "' ]";
result = service.queryResource(FILE_NAME, query);
assertEquals(1, result.getSize());
}
Aggregations