Reputation: 2795
I've downloaded the .NET Saxon API. I've compiled and run the EE sample application. Some of it required the license to be present, and I have a license file, which seemed to make it work.
I wanted to use xsl:import-schema
in my xslt, and this xslt works in the Oxygen editor (which has its own EE license).
If I take the simple xslt example from the saxon sample and then attempt to get it to compile my xslt with the import-schema
instruction I get:
Saxon.Api.StaticError: 'xsl:import-schema requires Saxon-EE'
That is true. However I am already explicitly referencing the Saxon EE library, so that shouldn't be an issue (see below for a clue):
Here's my code:
var samplesDir = new Uri(AppDomain.CurrentDomain.BaseDirectory);
String dir = samplesDir.LocalPath;
String sourceFile = Path.Combine(dir,"po.xml");
String styleFile = Path.Combine(dir,"po.xsl");
// Create a Processor instance.
Processor processor = new Processor();
// Load the source document
DocumentBuilder builder = processor.NewDocumentBuilder();
builder.BaseUri = new Uri(sourceFile);
XdmNode input = builder.Build(File.OpenRead(sourceFile));
XsltCompiler compiler = processor.NewXsltCompiler();
//compiler.SchemaAware = true;
compiler.BaseUri = new Uri(styleFile);
// fails on next line
Xslt30Transformer transformer = compiler.Compile(File.OpenRead(styleFile)).Load30();
// Set the root node of the source document to be the global context item
transformer.GlobalContextItem = input;
// Create a serializer, with output to the standard output stream
Serializer serializer = processor.NewSerializer();
serializer.SetOutputWriter(Console.Out);
// Transform the source XML and serialize the result document
transformer.ApplyTemplates(input, serializer);
Note that if I comment out the explicit setting to set the SchemaAware
setting to true, it says:
net.sf.saxon.trans.LicenseException
HResult=0x80131500
Message=Requested feature (schema-aware XSLT) requires Saxon-EE. You are using Saxon-EE software, but the Configuration is an instance of net.sf.saxon.Configuration; to use this feature you need to create an instance of com.saxonica.config.EnterpriseConfiguration
Source=saxon9ee
StackTrace:
at net.sf.saxon.Configuration.checkLicensedFeature(Int32 feature, String name, Int32 localLicenseId)
at net.sf.saxon.PreparedStylesheet..ctor(Compilation compilation)
at net.sf.saxon.style.StylesheetModule.loadStylesheet(Source styleSource, Compilation compilation)
at net.sf.saxon.style.Compilation.compileSingletonPackage(Configuration config, CompilerInfo compilerInfo, Source source)
at net.sf.saxon.s9api.XsltCompiler.compile(Source source)
at Saxon.Api.XsltCompiler.Compile(Stream input)
at ValidateXslt.Program.Main(String[] args) in C:\Users\m_r_n\source\repos\SaxonEEExample\ValidateXslt\Program.cs:line 33
This is a better clue. It's telling me I am using saxon EE, but I need an instance of com.saxonica.config.EnterpriseConfiguration
somehow.
Why am I getting this error message?
Upvotes: 0
Views: 355
Reputation: 2795
you need to tell the processor to behave like a licensed copy (seems a bit odd)
Processor processor = new Processor(true);
Simple, I'd copied an example that didnt need fancy features, but I'll leave this question as it is, just in case someone else has the same issue.
Upvotes: 1