0

We want to run XSpec as part of our Maven builds to check our XSL transformations. A plugin is available from GitHub. The problem arises when the XSL-stylesheets we check against invoke functions are not available in the Saxon-HE, looking like this:

Error at xsl:if on line 194 column 75 of dyxml_table_cals.xsl:
XPST0017 XPath syntax error at char 0 on line 194 near {...table-enumeration-condition...}:
Cannot find a matching 2-argument function named {http://saxon.sf.net/}evaluate().
Saxon extension functions are not available under Saxon-HE

We own licenses for the PE. According to the Saxon documentation the enhanced editions revert back to the open source HE when no license information is available, which seems to be the case. Is it possible to activate the PE by way of Maven, e.g. using the plugin by codehaus, and how would that look like? We already use a way of activation through Java, but to know of another, arguably more elegant way would be helpful, if possible at all.

styps
  • 279
  • 2
  • 14

2 Answers2

0

I'm not very familiar with the Maven plugins for XSpec but I try to give some hints and workarounds.

The pom.xml of the Maven plugin you mentioned contains a dependency to the version of Saxon used:

<dependency>
    <groupId>net.sf.saxon</groupId>
    <artifactId>Saxon-HE</artifactId>
    <version>9.7.0-1</version>
</dependency>

You should specify the Saxon version in order to use Saxon-PE or Saxon-EE. However, these Saxon versions don't seem to be available on public Maven repositories as, unlike Saxon-HE, they are proprietary software. I guess you can put the .jar file for Saxon-PE in a local repository (see Maven documentation for this). I suggest to put the .lic license file in the same directory as the .jar file.

Other two hints that may help you find a workaround:

  • XSpec allows to specify the Saxon version in an environment variable inside a shell or batch script. You can then run a shell script in your Maven project using for example the exec-maven-plugin. It's not ideal but it may be enough for your use case.
  • There is another Maven plugin for running XSpec, you may want to check that out too.

Hope it helps...

cirulls
  • 66
  • 1
  • 5
  • Thanks for the help. I tried the first way you suggested: Pulling the plugin-code from GitHub and replacing the dependency. However, now the problem seems to be that the Saxon distribution is not finding the license (it is placed within the same directory as the SaxonPE.jar). By now, we found a solution which I will post as a separate answer. – styps Sep 26 '16 at 08:48
  • Picking up the license from the directory containing the JAR is something that seems to work with most configurations but not all. I think it depends on the ClassLoader in use. – Michael Kay Sep 26 '16 at 17:01
0

After some trial and error we found following solution to be working:

  1. The creator of the XSpec-Maven-Plugin linked above hardcoded the use of the unlicensed Saxon-HE. In particular, following line was causing issues:

    private final static Processor processor = new Processor(false);
    

    We forked the code and changed it to:

    private final static Processor processor = new Processor(true);
    
  2. We built a custom class to activate the license and integrated it into the plugin source code. (Can`t post the code here.)

This resolved the licensing issue. Now our XSpec tests are up and running. Yeah us!

styps
  • 279
  • 2
  • 14