Project

Profile

Help

Bug #2713 ยป NPEfromCatch.java

Gunther Rademacher, 2016-04-15 15:19

 
import net.sf.saxon.Configuration;
import net.sf.saxon.expr.XPathContext;
import net.sf.saxon.lib.CollectionFinder;
import net.sf.saxon.lib.ResourceCollection;
import net.sf.saxon.s9api.Processor;
import net.sf.saxon.s9api.XQueryCompiler;
import net.sf.saxon.s9api.XQueryExecutable;
import net.sf.saxon.trans.XPathException;

public class NPEfromCatch {
public static void main(String[] args) throws Exception {
Configuration configuration = new Configuration();
configuration.setCollectionFinder(new CollectionFinder() {
@Override
public ResourceCollection findCollection(XPathContext paramXPathContext, String paramString) throws XPathException {
throw new XPathException("Class " + getClass().getName() + " refused to find collection " + paramString);
}
});
Processor processor = new Processor(configuration);
XQueryCompiler xqueryCompiler = processor.newXQueryCompiler();
XQueryExecutable xqueryExecutable = xqueryCompiler.compile("try {collection('file:///c:/TEMP?select=test.xml')} catch err:FODC0002 {'caught'}");
xqueryExecutable.load().run(processor.newSerializer(System.out));
}
}
    (1-1/1)