【问题标题】:xsl number()-function cannot convertxsl number() - 函数无法转换
【发布时间】:2011-10-31 12:42:33
【问题描述】:

我在 .NET 应用程序中使用 fop 1.0。
我的样式表看起来像

<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet ... version="1.0" ...>
...
<xsl:param name="fromPerson" select="'1'"/>
<xsl:param name="toPerson" select="'1'"/>
...
<xsl:template match="*[local-name()='Person']">
   <xsl:if test="(position() &gt;= number($fromPerson))>
   ...
   </xsl:if>
</xsl:template>

问题是函数 number() 失败:

Zeilennummer221; Spaltennummer267; #UNKNOWN (cli.System.Int32) kann nicht in eine Zahl
konvertiert werden!
(Position des Fehlers unbekannt)org.apache.fop.fo.ValidationException: "fo:root"
is missing child elements. Required content model: (layout-master-set, declarations?,  
bookmark-tree?, (page-sequence|fox:external-document)+) (Keine Kontextinformationen  
verf³gbar)

重要:

#UNKNOWN (cli.System.Int32) cannot be converted into an integer

顺便说一句:我通过使用

打印出值来测试它 知道为什么这会引发错误吗?

【问题讨论】:

    标签: xslt apache-fop


    【解决方案1】:

    可以传递给全局样式表参数的值类型取决于处理器的 API。我猜您使用的处理器的 API 不允许 cli.System.Int32 类型的值。

    确实,此处列出了 Microsoft API 接受的类型:

    http://msdn.microsoft.com/en-us/library/system.xml.xsl.xsltargumentlist.addparam.aspx

    【讨论】:

      【解决方案2】:

      我认为您需要&lt;xsl:variable&gt;,而不是&lt;xsl:param&gt;。参数是 &lt;xsl:template&gt; 元素的子元素(或在 XSLT 2 中的 &lt;xsl:function&gt; 元素。

      【讨论】:

      • 你错了。如果指定为顶部元素,则参数可以从外部传递给 xslt,就像这里一样。这在 xslt 1.0 和 2.0 中是可能的。
      • 我不知道,我认为#UNKNOWN 包含在变量 $fromPerson 而不是参数 $fromPerson 中。
      猜你喜欢
      • 1970-01-01
      • 2017-02-08
      • 1970-01-01
      • 2012-05-24
      • 2019-01-17
      • 2021-09-17
      • 2015-05-29
      • 2021-12-23
      • 2016-02-12
      相关资源
      最近更新 更多