0

Looking to run the simplest possible example using saxon, and, specifically, Saxon-HE:

thufir@dur:~/NetBeansProjects/helloWorldSaxon$ 
thufir@dur:~/NetBeansProjects/helloWorldSaxon$ gradle clean run

> Task :compileJava FAILED
/home/thufir/NetBeansProjects/helloWorldSaxon/src/main/java/helloWorldSaxon/App.java:6: error: package com.saxonica.xqj does not exist
import com.saxonica.xqj.SaxonXQDataSource;
                       ^
1 error

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileJava'.
> Compilation failed; see the compiler error output for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 0s
2 actionable tasks: 2 executed
thufir@dur:~/NetBeansProjects/helloWorldSaxon$ 

I don't think that's the right import statement, but neither am I sure what would be correct. A closer look at the sample reveals that it's using saxonica and has actually commented out the import:

//import net.sf.saxon.xqj.SaxonXQDataSource;

To re-iterate, would want to stay within Saxon-HE. But how?

From the build file:

compile (group = "net.sf.saxon"            , name = "Saxon-HE"    , version = "9.9.0-2")

Sticking to Saxon-HE this is the correct import?

Which data source does this ship with?

thufir@dur:~/saxon$ 
thufir@dur:~/saxon$ jar tf Saxon-HE.jar | grep data
net/sf/saxon/data/
net/sf/saxon/data/analyze-string.xsd
net/sf/saxon/data/casevariants.xml
net/sf/saxon/data/categories.xml
net/sf/saxon/data/chameleon.xsl
net/sf/saxon/data/json.xsd
net/sf/saxon/data/normalizationData.xml
net/sf/saxon/data/override.xsl
net/sf/saxon/data/unicodeBlocks.xml
net/sf/saxon/data/xml-to-json-indent.xsl
net/sf/saxon/data/xml-to-json-pkg.xsl
net/sf/saxon/data/xml-to-json.xsl
net/sf/saxon/data/xpath-functions.scm
net/sf/saxon/data/xpath-functions.xsd
net/sf/saxon/resource/MetadataResource$1.class
net/sf/saxon/resource/MetadataResource.class
thufir@dur:~/saxon$ 

Do I need more compile dependencies? If so, which ones?

Thufir
  • 8,216
  • 28
  • 125
  • 273

1 Answers1

2

The class SaxonXQDataSource is in package com.saxonica.xqj. If you are using Saxon-HE, then you will need to have the JAR file saxon9-xqj.jar on the classpath.

The reason Saxon's XQJ library is treated differently from the rest of Saxon-HE is that the licensing is different. The XQJ interface is published by Oracle, and Oracle claim that implementations are subject to the Oracle licensing conditions (some people dispute that implementing a published API requires a license, but that's a matter for the lawyers). The Oracle licensing conditions don't conform to the accepted standards for open source licensing (for two reasons: (a) they disallow modifications, and (b) they require implementations to pass all the reference tests). For this reason some software companies who redistribute Saxon-HE prefer to exclude XQJ from the distribution, and to make this easy, we put the XQJ classes in a separate JAR file.

Michael Kay
  • 156,231
  • 11
  • 92
  • 164