Page 1 of 1

XSLT via ANT fails in Oxygen-17.0

Posted: Tue May 12, 2015 2:44 pm
by Ron Van den Branden
Hi,

In an Oxygen project I have defined an ANT transformation invoking an XSLT transformation, via the Java ANT task:

Code: Select all


  <target name="xslt">
<java classname="net.sf.saxon.Transform">
<arg value="-s:${in}"/>
<arg value="-xsl:${xslt}"/>
<arg value="-o:${out}"/>
</java>
</target>
This worked flawlessly with Oxygen-16.1, but after updating to Oxygen-17.0, this task fails with following error message, which isn't very enlightening to me:

Code: Select all


xslt:
[java] java.lang.RuntimeException: Internal error evaluating template at line 149 in module file:/C:/test-xslt.xsl
[java] at net.sf.saxon.expr.instruct.Template.applyLeavingTail(Unknown Source)
[java] at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:1155)
[java] at net.sf.saxon.trans.TextOnlyCopyRuleSet.process(TextOnlyCopyRuleSet.java:65)
[java] at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:1131)
[java] at net.sf.saxon.Controller.transformDocument(Unknown Source)
[java] at net.sf.saxon.Controller.transform(Unknown Source)
[java] at net.sf.saxon.s9api.XsltTransformer.transform(XsltTransformer.java:547)
[java] at net.sf.saxon.Transform.processFile(Transform.java:1056)
[java] at net.sf.saxon.Transform.doTransform(Transform.java:659)
[java] at net.sf.saxon.Transform.main(Transform.java:80)
[java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[java] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
[java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
[java] at java.lang.reflect.Method.invoke(Unknown Source)
[java] at org.apache.tools.ant.taskdefs.ExecuteJava.run(ExecuteJava.java:217)
[java] at org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava.java:152)
[java] at org.apache.tools.ant.taskdefs.Java.run(Java.java:771)
[java] at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:221)
[java] at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:135)
[java] at org.apache.tools.ant.taskdefs.Java.execute(Java.java:108)
[java] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
[java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[java] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
[java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
[java] at java.lang.reflect.Method.invoke(Unknown Source)
[java] at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
[java] at org.apache.tools.ant.Task.perform(Task.java:348)
[java] at org.apache.tools.ant.Target.execute(Target.java:435)
[java] at org.apache.tools.ant.Target.performTasks(Target.java:456)
[java] at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1393)
[java] at org.apache.tools.ant.Project.executeTarget(Project.java:1364)
[java] at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
[java] at org.apache.tools.ant.Project.executeTargets(Project.java:1248)
[java] at org.apache.tools.ant.Main.runBuild(Main.java:851)
[java] at org.apache.tools.ant.Main.startAnt(Main.java:235)
[java] at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
[java] at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)
[java] Caused by: java.lang.RuntimeException: Internal error evaluating template at line 1107 in module file:/C:/test-xslt.xsl
[java] at net.sf.saxon.expr.instruct.Template.applyLeavingTail(Unknown Source)
[java] at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:1155)
[java] at net.sf.saxon.expr.instruct.ApplyTemplates.apply(ApplyTemplates.java:287)
[java] at net.sf.saxon.expr.instruct.ApplyTemplates.processLeavingTail(ApplyTemplates.java:247)
[java] at net.sf.saxon.expr.instruct.Block.processLeavingTail(Block.java:672)
[java] at net.sf.saxon.expr.instruct.Instruction.process(Unknown Source)
[java] at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:452)
[java] at net.sf.saxon.expr.instruct.Copy.processLeavingTail(Copy.java:468)
[java] ... 37 more
[java] Caused by: java.lang.ClassCastException: net.sf.saxon.expr.instruct.UserFunction cannot be cast to net.sf.saxon.expr.instruct.GlobalVariable
[java] at net.sf.saxon.expr.GlobalVariableReference.evaluateVariable(GlobalVariableReference.java:100)
[java] at net.sf.saxon.expr.VariableReference.evaluateItem(VariableReference.java:464)
[java] at net.sf.saxon.functions.KeyFn.iterate(KeyFn.java:260)
[java] at net.sf.saxon.expr.LetExpression.iterate(LetExpression.java:388)
[java] at net.sf.saxon.expr.instruct.ForEach.processLeavingTail(ForEach.java:384)
[java] at net.sf.saxon.expr.instruct.Template.expand(Unknown Source)
[java] at net.sf.saxon.expr.instruct.CallTemplate.process(CallTemplate.java:347)
[java] at net.sf.saxon.expr.instruct.CallTemplate.processLeavingTail(CallTemplate.java:401)
[java] at net.sf.saxon.expr.instruct.Block.processLeavingTail(Block.java:672)
[java] at net.sf.saxon.expr.instruct.Instruction.process(Unknown Source)
[java] at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(ElementCreator.java:452)
[java] at net.sf.saxon.expr.instruct.Copy.processLeavingTail(Copy.java:468)
[java] ... 45 more
[java] Fatal error during transformation: java.lang.RuntimeException: Internal error evaluating template at line 149 in module file:/C:/test-xslt.xsl
[java] Java Result: 2

BUILD SUCCESSFUL
Total time: 2 seconds

The process finished with exit code: 0
Yet, when the same XSLT transformation is executed via an XSLT task, or just in the Oxygen XSLT view, there is no problem at all, so I don't think there's anything wrong with the XSLT stylesheet. Also, as I said before, this worked (and still does) in Oxygen-16.1. The problem seems related to the specific XSLT stylesheet; when I replace it with other XSLT stylesheets, the ANT task succeeds even in Oxygen-17.0.

Has anything changed in the way Oxygen17.0 executes ANT transformations, or in how it calls the Saxon XSLT processor from ANT tasks?

Best,

Ron

Re: XSLT via ANT fails in Oxygen-17.0

Posted: Tue May 12, 2015 4:06 pm
by adrian
Hi,

Oxygen 17.0 includes Saxon 9.6. That is the main difference between 16.1 and 17.0 regarding XSLT processing. The problem is here:

Code: Select all

     [java] Caused by: java.lang.ClassCastException: net.sf.saxon.expr.instruct.UserFunction cannot be cast to net.sf.saxon.expr.instruct.GlobalVariable
There's something in your XSLT that triggers this with Saxon 9.6.
We do not have the means to reproduce this on our side. Could you please send us the involved XSLT stylesheet so we can test this?
Please send it to our support email address, support@oxygenxml.com.

Regards,
Adrian

Re: XSLT via ANT fails in Oxygen-17.0

Posted: Mon May 18, 2015 1:23 pm
by Ron Van den Branden
Hi,

As a follow-up, this error seemed to boil down to a classpath issue. Meanwhile, this issue has been fixed in the latest Oxygen build (Build ID: 2015051321).

Thanks for investigating and fixing this!

Ron

Re: XSLT via ANT fails in Oxygen-17.0

Posted: Mon May 18, 2015 3:28 pm
by adrian
Hello,

To clarify, there was a missing Saxon 9.6 patch in the original build of Oxygen 17.0, 2015043018, that was causing this problem. This has been addressed in build 2015051321 of v17.0 (released on May 15th).

Regards,
Adrian