use of org.xmldb.api.base.ResourceIterator in project exist by eXist-db.
the class LocalXMLResourceDOMTest method testEnhancer02.
@Test
public void testEnhancer02() throws XMLDBException {
final ResourceSet rs1 = existEmbeddedServer.executeQuery("doc('" + TestConstants.TEST_COLLECTION_URI.getRawCollectionPath() + "/" + TEST_RESOURCE_NAME + "')//properties/property[@key='type' and text()='Table']");
for (final ResourceIterator i1 = rs1.getIterator(); i1.hasMoreResources(); ) {
final XMLResource r1 = (XMLResource) i1.nextResource();
final Map<String, Object> variables = new HashMap<>();
variables.put("local:document", r1.getContentAsDOM());
final String query = "xquery version \"1.0\";" + "declare namespace xmldb=\"http://exist-db.org/xquery/xmldb\";" + "declare variable $local:document external;" + "$local:document";
final ResourceSet rs2 = existEmbeddedServer.executeQuery(query, variables);
for (final ResourceIterator i2 = rs2.getIterator(); i2.hasMoreResources(); ) {
final XMLResource r2 = (XMLResource) i2.nextResource();
final Node content2 = r2.getContentAsDOM();
assertNotNull(content2);
}
}
}
use of org.xmldb.api.base.ResourceIterator in project exist by eXist-db.
the class LocalXMLResourceDOMTest method testEnhancer01.
@Test
public void testEnhancer01() throws XMLDBException {
final String query = "doc('" + TestConstants.TEST_COLLECTION_URI.getRawCollectionPath() + "/" + TEST_RESOURCE_NAME + "')//properties[property[@key eq 'type'][text() eq 'Table']]";
final ResourceSet rs1 = existEmbeddedServer.executeQuery(query);
final ResourceSet rs2 = existEmbeddedServer.executeQuery(query);
final ResourceIterator i1 = rs1.getIterator();
final ResourceIterator i2 = rs2.getIterator();
for (; i1.hasMoreResources() && i1.hasMoreResources(); ) {
final XMLResource r1 = (XMLResource) i1.nextResource();
final XMLResource r2 = (XMLResource) i2.nextResource();
assertEquals(r1.getContentAsDOM(), r2.getContentAsDOM());
}
}
Aggregations