如何解决Saxon.Api.StaticError:'xsl:import-schema需要Saxon-EE'与.net API
我已经下载了Saxon API(实际上是dotnet)。 我已经准备好EE示例应用程序,对其进行编译并运行。 其中一些需要许可证,并且我有一个许可证文件,似乎可以使它起作用。
我想在xslt中使用xsl:import-schema,并且此xslt可在氧气中使用(它具有自己的EE许可证)。
如果我从saxon示例中获取简单的xslt示例,然后尝试使用得到的import-schema指令使其编译xslt。
Wed Jan 06 00:00:00 CET 2021
这是真的...但是...我明确地引用了Saxon EE库,因此这不应该成为问题(请参见下面的更多线索)。
我的代码是这个
Saxon.Api.StaticError: 'xsl:import-schema requires Saxon-EE'
请注意,如果我注释掉将SchemaAware设置设置为true的显式设置,它会显示
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);
这是一个更好的线索...它告诉我我正在使用saxon EE,但我需要以某种方式使用com.saxonica.config.EnterpriseConfiguration的实例。
如何?!
解决方法
您需要让处理器表现得像许可副本(看起来有些奇怪)
Processor processor = new Processor(true);
很简单,我复制了一个不需要花哨功能的示例,但是我将保留这个问题,以防万一其他人遇到相同的问题。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。