Saxon:缩进空格属性被忽略



在我的问题中,我试图将参数传递给我的样式表,以便用户可以指定所需的缩进级别。 显然,Xalan 无法将参数的值读取到其 indent-amount 属性中,所以我正在尝试使用这个版本的 Saxon-HE 来代替。

撒克逊具有我尝试使用的属性缩进空格,如下所示:

<xsl:stylesheet
    version="2.0"
    xmlns:saxon="http://saxon.sf.net"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <!-- <xsl:param name="indent-spaces" select="0"/> -->
    <xsl:output indent="yes" method="xml" omit-xml-declaration="yes" saxon:indent-spaces="10"/><!-- Doesn't matter what I make the value of indent-spaces, the output is always indented 3 spaces -->

为什么indent-spaces被忽略了?

命名空间

应该是xmlns:saxon="http://saxon.sf.net/"而不是xmlns:saxon="http://saxon.sf.net"

首先,所有撒克逊扩展都需要 Saxon-PE 或更高版本。

其次,如果你想动态控制序列化参数(例如,从样式表参数,你可以使用 xsl:result-document 来做到这一点:

<xsl:result-document indent="yes" saxon:indent-spaces="{$param}">
  ...
</xsl:result-document>

最新更新