Project

Profile

Help

Bug #4999 ยป CompileTest.java

Taras Chervinka, 2021-05-25 17:02

 
import com.saxonica.config.EnterpriseConfiguration;
import com.saxonica.config.ProfessionalConfiguration;
import net.sf.saxon.s9api.Processor;
import net.sf.saxon.s9api.XQueryCompiler;
import net.sf.saxon.s9api.XQueryExecutable;
import java.io.*;


public class CompileTest {
private static String key =
"";


private static String deobfuscate(String x) {
String digits = "";
StringBuffer buff = new StringBuffer(x.length());
for (int i = x.length() - 1; i >= 0; i -= 2) {
int c1 = digits.indexOf(x.charAt(i));
int c2 = digits.indexOf(x.charAt(i - 1));
buff.append((char) (c1 << 4 | c2));
}
return buff.toString();
}

// Activate a ProfessionalConfiguration or EnterpriseConfiguration
public static void activate(ProfessionalConfiguration config) {
config.supplyLicenseKey(new BufferedReader(new StringReader(deobfuscate(key))));
}

// Activate Saxon at the level of a s9api Processor
public static void activate(Processor processor) {
processor.setConfigurationProperty("http://saxonica.com/oem-data", deobfuscate(key));
}

public static void testCompile() {
EnterpriseConfiguration pc = new EnterpriseConfiguration();
// ProfessionalConfiguration pc = new ProfessionalConfiguration();
activate(pc);
Processor processor = new Processor(pc);
XQueryCompiler compiler = processor.newXQueryCompiler();
compiler.setLanguageVersion("3.0"); //$NON-NLS-1$

String expr = "declare variable $selectedService as item()* external;\n"
+ "declare variable $wsdlDoc as item()* external;\n"
+ "$wsdlDoc/binding[local-name-from-QName(resolve-QName(@type, $wsdlDoc))=$selectedService] \n";

try{
XQueryExecutable executable = compiler.compile(expr);
System.out.println(pc.toString() + " OK");
} catch (Exception e)
{
e.printStackTrace();
}
}

public static void main(String[] args) {
testCompile();
}
}
    (1-1/1)