} else {
log( msg, Project.MSG_ERR );
}
} else {
final XQueryService service = (XQueryService)base.getService( "XQueryService", "1.0" );
// set pretty-printing on
service.setProperty( OutputKeys.INDENT, "yes" );
service.setProperty( OutputKeys.ENCODING, "UTF-8" );
for( final Variable var : variables ) {
System.out.println( "Name: " + var.name );
System.out.println( "Value: " + var.value );
service.declareVariable( var.name, var.value );
}
ResourceSet results = null;
Source source = null;
if( queryUri != null ) {
log( "XQuery url " + queryUri, Project.MSG_DEBUG );
if( queryUri.startsWith( XmldbURI.XMLDB_URI_PREFIX ) ) {
final Resource resource = base.getResource( queryUri );
source = new BinarySource( (byte[])resource.getContent(), true );
} else {
source = new URLSource( new URL( queryUri ) );
}
} else if( queryFile != null ) {
log( "XQuery file " + queryFile.getAbsolutePath(), Project.MSG_DEBUG );
source = new FileSource( queryFile, "UTF-8", true );
} else {
log( "XQuery string: " + query, Project.MSG_DEBUG );
source = new StringSource( query );
}
results = service.execute( source );
log( "Found " + results.getSize() + " results", Project.MSG_INFO );
if( ( destDir != null ) && ( results != null ) ) {
log( "write results to directory " + destDir.getAbsolutePath(), Project.MSG_INFO );
final ResourceIterator iter = results.getIterator();