|
package cw.validation.streaming.impl.saxon;
|
|
|
|
import java.io.IOException;
|
|
|
|
import net.sf.saxon.Configuration;
|
|
import net.sf.saxon.s9api.ExtensionFunction;
|
|
import net.sf.saxon.s9api.Processor;
|
|
import net.sf.saxon.s9api.SaxonApiException;
|
|
import net.sf.saxon.s9api.XPathCompiler;
|
|
import net.sf.saxon.s9api.XPathExecutable;
|
|
import net.sf.saxon.s9api.XPathSelector;
|
|
import net.sf.saxon.s9api.XdmValue;
|
|
|
|
import org.junit.Assert;
|
|
import org.junit.BeforeClass;
|
|
import org.junit.Test;
|
|
|
|
import com.google.common.io.Resources;
|
|
|
|
public class XsltHelperTest2 {
|
|
private static final Configuration CONFIG = Configuration.newConfiguration();
|
|
private static Processor proc;
|
|
|
|
@BeforeClass
|
|
public static void setup() throws SaxonApiException, IOException {
|
|
proc = new Processor(CONFIG);
|
|
XsltHelperV96 helper = new XsltHelperV96(proc);
|
|
helper.compile(Resources.getResource(XsltHelperTest2.class, "/foo.xsl"));
|
|
for (ExtensionFunction f : helper.getExtensionFunctions()) {
|
|
proc.registerExtensionFunction(f);
|
|
}
|
|
}
|
|
|
|
@Test
|
|
public void testFunction() throws SaxonApiException {
|
|
XPathCompiler comp = proc.newXPathCompiler();
|
|
comp.declareNamespace("util", "foo:util");
|
|
XPathExecutable complied = comp.compile("util:unsortedValues('FOO BAZ', ('FOO', 'BAR', 'BAZ'))");
|
|
XPathSelector loaded = complied.load();
|
|
XdmValue res = loaded.evaluate();
|
|
Assert.assertEquals("", res.toString());
|
|
}
|
|
}
|