Saxon .net 如何处理外部资源 xml

Saxon .net how handle external resources xml

我有一个批次,想在 .net 应用程序中重建它。我如何在 .net 中处理这个问题?

-xsl:"style.xsl" resource-path="%runtimepath%%respath%" srcAutotexte="%runtimepath%%respath%\autotext\autotext.xml" 

我的尝试。如何包含 autotext.xml?

        // Create a transformer for the stylesheet.
        XsltCompiler compiler = processor.NewXsltCompiler();
        compiler.BaseUri = new Uri(styleXslFilePath);
        XsltTransformer transformer = compiler.Compile(File.OpenRead(styleXslFilePath)).Load();

命令行选项

 resource-path="%runtimepath%%respath%"
 srcAutotexte="%runtimepath%%respath%\autotext\autotext.xml" 

在转换中设置样式表参数的值。

使用Saxon.Api接口的等价物是调用

    transformer.SetParameter(
         new QName("resource-path"), 
         new XdmAtomicValue("%runtimepath%%respath%"));

等等

(也许您的 shell 将 %xxxx% 解释为对某种 shell/system 变量的引用 - 我已经很久没有在 Windows 下编写批处理脚本了。如果那是在这种情况下,您将需要掌握这些变量的值。您可以使用 .NET API 在 C# 级别执行此操作,或者您可以使用 [=XSLT 3.0 中的 environment-variable() 函数。)