【问题标题】:Saxon .Net transformation撒克逊 .Net 转型
【发布时间】:2015-10-27 09:45:53
【问题描述】:

也许这是一个愚蠢的问题,但我是 XSL 的新手。

我正在使用这个命令行来执行一个效果很好的转换:

transform.exe -s: source.xml -xsl:rules.xsl -o: output.xml -xi:on

我试图从 c# 中获得相同的结果,但输出文件为空。 “-xi”参数的等价物是什么?

谢谢。

  Uri xslUri = new Uri(@"rules.xsl");
  Uri inputUri = new Uri(@"source.xml");
  Uri outputUri = new Uri(@"toc.hhc");

  // Compile stylesheet
  try
  {
    Processor processor = new Processor();
    XdmNode input = processor.NewDocumentBuilder().Build(inputUri);
    XsltCompiler compiler = processor.NewXsltCompiler();
    XsltExecutable exec = compiler.Compile(xslUri);
    XsltTransformer transformer = exec.Load();
    transformer.InitialContextNode = input;

    // Create a serializer
    Serializer serializer = new Serializer();
    FileStream fs = new FileStream(outputUri.AbsolutePath, FileMode.Create, FileAccess.Write);
    serializer.SetOutputStream( fs );

    // Transform the source XML to System.out.
    transformer.Run( serializer );
  }
  catch( Exception e )
  {
    Console.WriteLine( e.Message );
  }

【问题讨论】:

标签: c# .net xslt saxon


【解决方案1】:

我尝试设置 proc.Implementation.setXIncludeAware(true);,但它不适用于 Saxon 9.6.0.7。因此我在https://saxonica.plan.io/boards/3/topics/6206 上发布了我的结果,Saxonica 创建了错误报告https://saxonica.plan.io/issues/2488,该报告稍后被修复。因此,您似乎必须等到该修复程序包含在新版本中才能在 .NET 应用程序中使用 XInclude。

【讨论】:

    【解决方案2】:

    我需要对其进行测试以 100% 确定它有效,但我认为您应该能够做到

    processor.setProperty("http://saxon.sf.net/feature/xinclude-aware", "true")
    

    【讨论】:

      猜你喜欢
      • 2019-03-11
      • 2016-01-25
      • 2010-10-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多