【问题标题】:saxon passing directory as a command line parameter to XSLT 2.0 style sheetsaxon 将目录作为命令行参数传递给 XSLT 2.0 样式表
【发布时间】:2020-04-27 18:15:32
【问题描述】:

使用 Saxon9he,我想将输入文件的目录传递给我的 XSLT 样式表。我在样式表中定义了参数:

<xsl:param name="publishing.folder" />

在命令行上:

+publishing.folder="%~dp1\"

+ 参数为空。

没有+

publishing.folder="%~dp1\" 

我得到:Error in xsl:result-document/@href Resolved URL is malformed: unknown protocol: d

d 可能是驱动器号,即输入文件所在的位置。

这是导致错误的带有@href 的代码:

    <xsl:template match="/">
      <xsl:call-template name="write-dataset-file">
            <xsl:with-param name="filename" select="concat($publishing.folder,'-dataset.xml')"/>
      </xsl:call-template>
    </xsl:template>

   <xsl:template name="write-dataset-file">
      <xsl:param name="filename"/>

      <xsl:result-document href="{$filename}" omit-xml-declaration="false" method="xml" indent="yes">
         <Dataset>

         </Dataset>
      </xsl:result-document>
  </xsl:template>

xalan 接受命令行参数-PARAM publishing.folder "%~dp1\",但我宁愿不回到 XSLT 1.0

【问题讨论】:

    标签: xml command-line xslt-2.0 saxon


    【解决方案1】:

    xsl:result-document 的 href 属性必须是 URI,但您正在构建文件名。尽管许多与 XML 相关的软件包接受标准需要 URI 的文件名,但 Saxon 往往更严格。解决此问题的最简单方法是在文件名的开头添加“file:///”,但如果文件名包含“#”等特殊字符,这可能不够。

    【讨论】:

    • 谢谢你,凯博士。我希望这对其他人有所帮助,因为我觉得自己像个 idjit。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-10-25
    • 1970-01-01
    • 2011-12-10
    • 2010-12-04
    • 2020-02-19
    • 1970-01-01
    相关资源
    最近更新 更多