我想在 xslt 模板中动态构建匹配。我使用 xls fo 和 apache fop 和 saxon9he。最好的方式是我想从 java 传递参数,但首先我尝试在 xslt 中设置它。
当我创建这样的变量示例时:
<xsl:variable name="testPath" select="/abc:Files/def:Description" />
如果我尝试在应用模板中使用它也可以正常工作:
<xsl:apply-templates select="$testPath/qwe:Test"/>
但我想动态设置 testPath 变量。我尝试使用选择标签:
<xsl:variable name="testPath">
<xsl:choose>
<xsl:when test="$versionNo = '2'">
<xsl:value-of select="/abc:Files/def:Description" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="/abc:Files/def:Names" />
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
但是这种方法不起作用,当我尝试使用这个变量时:
<xsl:apply-templates select="$testPath/qwe:Test"/>
我收到此错误:
在 pdf_gen.xsl 的第 82 行第 21 列评估 ((attr{table-layout=...}, ...)) 时出错:SXCH0003: org.apache.fop.fo.ValidationException: "fo:table-body" 是缺少子元素。所需内容模型:marker* (table-row+|table-cell+)(见位置 82:21):
file:/C:/Users/SuperUser/workspace/project/xls-editor/target/classes/pdf/xsl/pdf_gen .xsl:82:21:“fo:table-body”缺少子元素。所需内容模型:marker* (table-row+|table-cell+)(见位置 82:21)
在最佳选择中,我想将 Java 中的 $testPath 变量作为参数传递,例如:
transformer.setParameter("testPath ", "/abc:Files/def:Description");
并在 xslt 中使用
<xsl:param name="testPath "/>
并在模板中应用:
<xsl:apply-templates select="$testPath/qwe:Test"/>
但我收到以下错误:
pdf_gen.xsl 的第 74 行第 60 列 xsl:apply-templates/@select 中的类型错误评估 ($testPath): XPTY0019: '/' 的第一个操作数所需的项目类型是 node(); 提供的值
u"/abc:Files/def:Description" 是一个原子值
为什么没有任何解决方案可以实现它?
qq_遁去的一_1
拉丁的传说
相关分类