Saxon.Api.StaticError: 'xsl:import-schema requires Saxon-EE' with .net API

0

I've downloaded the Saxon API (actually the dotnet one). I've taken the EE sample application, compiled it and run it. Some of it required the licence 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 oxygen (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'

which is true...but...I am explicitly referencing the Saxon EE library, so that shouldnt be an issue (see below for further clue).

my code is this

        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 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...its telling me I AM using saxon EE, but I need an instance of com.saxonica.config.EnterpriseConfiguration somehow.

how?!

xslt
saxon

1 Answer

0

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.


User contributions licensed under CC BY-SA 3.0