cfoster / saxon-jing

Extension Functions allowing Saxon to validate documents against RelaxNG Schemas
http://www.cfoster.net/saxon-jing/
Other
11 stars 3 forks source link

Patched for Saxon 9.9+ #8

Open Arithmeticus opened 3 years ago

Arithmeticus commented 3 years ago

Patch for Saxon 9.9+.

cfoster commented 3 years ago

Hi Joel,

I think I can now see from Issue #6, the version of Saxon shipped with oXygen v22 may not have a getProcessor() method.

Saxon-Jing makes use of higher-order functions which used to be only available in Saxon EE, but are now fully available in Saxon HE from Saxon 10 onwards.

I think it would be really great if we can get the Java code working with both the previous EE binaries and the latest HE 10 version if we can.

I've changed the Maven POM file, but the core Java code I used is:

Processor proc = null;
try { 
  proc = (Processor)config.getProcessor();
} catch(Throwable e) { /* do nothing */ }

if(proc == null)
  proc = new Processor(config);
config.registerExtensionFunction(new SchemaFunction());
config.registerExtensionFunction(new SchemaReportFunction(proc));

I've uploaded a snapshot binary of this here at:

http://www.cfoster.net/zip/temp/saxon-jing-0.9.3.jar

Could you please tell me if this works for you? Like perhaps in your version of oXygen and if it just "fits in" with whatever setup you've got going at the moment?

Arithmeticus commented 3 years ago

Thanks, Charles. I've tested your 0.9.3 jar file both on the command line (CL) and in Oxygen, keeping configurations that worked with saxon-jing-0.9.2.

CL, EE 9.8: java error (I'll send error report separately) CL, EE 9.9+: can't test: no license CL, HE 10.3: success (so great to see HE able to run RNC validation reports!)

Ox21, EE 9.8: fail (net.sf.saxon.om.NodeInfo.iterateAxis(I)Lnet/sf/saxon/tree/iter/AxisIterator;) Ox22, EE 9.9: fail (net.sf.saxon.om.NodeInfo.iterateAxis(I)Lnet/sf/saxon/tree/iter/AxisIterator;)

Let me know what other tests you might want me to run.

Arithmeticus commented 3 years ago

Command line, Saxon 9.8 EE with saxon-jing-0.9.3:

Exception in thread "main" java.lang.NoSuchMethodError: net.sf.saxon.om.NodeInfo.iterateAxis(I)Lnet/sf/saxon/tree/iter/AxisIterator;
        at net.cfoster.saxonjing.SchemaReportApplierFunction.call(SchemaReportApplierFunction.java:127)
        at net.sf.saxon.functions.CallableFunction.call(CallableFunction.java:121)
        at net.sf.saxon.functions.SystemFunction.dynamicCall(SystemFunction.java:451)
        at net.sf.saxon.functions.ApplyFn.call(ApplyFn.java:159)
        at net.sf.saxon.expr.FunctionCall.iterate(FunctionCall.java:547)
        at net.sf.saxon.expr.instruct.CopyOf.iterate(CopyOf.java:893)
        at com.saxonica.ee.bytecode.ByteCodeCandidate.iterate(ByteCodeCandidate.java:313)
        at net.sf.saxon.expr.parser.ExpressionTool.evaluate(ExpressionTool.java:341)
        at net.sf.saxon.expr.parser.ExpressionTool.eagerEvaluate(ExpressionTool.java:464)
        at net.sf.saxon.expr.TryCatch.iterate(TryCatch.java:262)
        at net.sf.saxon.expr.LetExpression.iterate(LetExpression.java:501)
        at net.sf.saxon.expr.ItemChecker.iterate(ItemChecker.java:227)
        at net.sf.saxon.expr.instruct.BlockIterator.next(BlockIterator.java:49)
        at net.sf.saxon.expr.CardinalityChecker.evaluateItem(CardinalityChecker.java:281)
        at net.sf.saxon.expr.instruct.Choose.evaluateItem(Choose.java:930)
        at net.sf.saxon.expr.parser.ExpressionTool.evaluate(ExpressionTool.java:329)
        at net.sf.saxon.expr.LetExpression.eval(LetExpression.java:519)
        at net.sf.saxon.expr.LetExpression.processLeavingTail(LetExpression.java:700)
        at net.sf.saxon.expr.instruct.Block.processLeavingTail(Block.java:687)
        at net.sf.saxon.expr.instruct.TemplateRule.applyLeavingTail(TemplateRule.java:347)
        at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:505)
        at net.sf.saxon.expr.instruct.ApplyTemplates.apply(ApplyTemplates.java:295)
        at net.sf.saxon.expr.instruct.ApplyTemplates.processLeavingTail(ApplyTemplates.java:252)
        at net.sf.saxon.expr.instruct.Block.processLeavingTail(Block.java:687)
        at net.sf.saxon.expr.instruct.Instruction.process(Instruction.java:151)
        at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:337)
        at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:284)
        at net.sf.saxon.expr.instruct.Instruction.process(Instruction.java:151)
        at net.sf.saxon.expr.LetExpression.process(LetExpression.java:596)
        at net.sf.saxon.expr.instruct.ForEach.processLeavingTail(ForEach.java:472)
        at net.sf.saxon.expr.instruct.Block.processLeavingTail(Block.java:687)
        at net.sf.saxon.expr.instruct.Instruction.process(Instruction.java:151)
        at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:337)
        at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:284)
        at net.sf.saxon.expr.instruct.Instruction.process(Instruction.java:151)
        at net.sf.saxon.expr.instruct.DocumentInstr.evaluateItem(DocumentInstr.java:302)
        at net.sf.saxon.expr.instruct.DocumentInstr.evaluateItem(DocumentInstr.java:50)
        at net.sf.saxon.expr.LetExpression.evaluateItem(LetExpression.java:549)
        at com.saxonica.ee.bytecode.ByteCodeCandidate.evaluateItem(ByteCodeCandidate.java:285)
        at net.sf.saxon.expr.parser.ExpressionTool.evaluate(ExpressionTool.java:329)
        at net.sf.saxon.expr.instruct.UserFunction.call(UserFunction.java:599)
        at net.sf.saxon.expr.UserFunctionCall.callFunction(UserFunctionCall.java:539)
        at net.sf.saxon.expr.UserFunctionCall.iterate(UserFunctionCall.java:485)
        at net.sf.saxon.expr.instruct.GlobalVariable.getSelectValue(GlobalVariable.java:643)
        at net.sf.saxon.expr.instruct.GlobalVariable.actuallyEvaluate(GlobalVariable.java:724)
        at net.sf.saxon.expr.instruct.GlobalVariable.evaluateVariable(GlobalVariable.java:692)
        at net.sf.saxon.expr.GlobalVariableReference.evaluateVariable(GlobalVariableReference.java:126)
        at net.sf.saxon.expr.VariableReference.iterate(VariableReference.java:538)
        at net.sf.saxon.expr.instruct.CopyOf.processLeavingTail(CopyOf.java:557)
        at net.sf.saxon.expr.instruct.Block.processLeavingTail(Block.java:687)
        at net.sf.saxon.expr.instruct.Instruction.process(Instruction.java:151)
        at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:337)
        at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:284)
        at net.sf.saxon.expr.instruct.TemplateRule.applyLeavingTail(TemplateRule.java:347)
        at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:505)
        at net.sf.saxon.Controller.transformDocument(Controller.java:2423)
        at net.sf.saxon.Controller.transform(Controller.java:1979)
        at net.sf.saxon.s9api.Xslt30Transformer.applyTemplates(Xslt30Transformer.java:592)
        at net.sf.saxon.Transform.processFile(Transform.java:1260)
        at net.sf.saxon.Transform.doTransform(Transform.java:783)
        at net.sf.saxon.Transform.main(Transform.java:82)
Arithmeticus commented 2 years ago

Charles, I had some time today to pursue this further. I took your source and recompiled on my end. Jar package here.

Interestingly, this compiled package performed the opposite as your jar file on all tests. That is, it worked fine in Oxygen 21 & 22 and CLI Saxon 9.8-9.9, but it threw the same NoSuchMethodFound error on the CLI for Saxon 10.3.

AFAICT all version of Saxon I've been testing include the iterateAxis() 1-arity method.

So there must be something awry in the build process. I've been using Maven 3.8.1 + Java JDK 12.0.1.

I'll keep playing around.