html - 如何在 XSLT1.0 的中间位置使用 xsl:template?
问题描述
我在我的 XSLT1.0 中的模板的上部使用它来从 xml 获取不同的数据值。
完整代码:- https://www.dropbox.com/s/6jollabe8tbbd7j/code.xslt?dl=0 在以下位置使用此块:- 第 745 行
而且我必须在我的 xslt 中间使用这个块,但是如何做到这一点。如果我使用它,我会遇到异常,因为样式表中的这个位置不允许使用 xsl:template!如何解决任何建议表示赞赏
<xsl:template match="COMBINED-PAYMENT-HISTORY">
<xsl:variable name="items-rtf">
<xsl:call-template name="tokenize">
<xsl:with-param name="text" select="normalize-space(.)"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="items" select="exsl:node-set($items-rtf)/item" />
<table>
<!-- month -->
<tr>
<xsl:for-each select="$items">
<td>
<xsl:value-of select="substring-before(., ':')" />
</td>
</xsl:for-each>
</tr>
<!-- year -->
<tr>
<xsl:for-each select="$items">
<td>
<xsl:value-of select="substring-before(substring-after(., ':'), ',')" />
</td>
</xsl:for-each>
</tr>
<!-- data -->
<tr>
<xsl:for-each select="$items">
<td>
<xsl:value-of select="substring-after(., ',')" />
</td>
</xsl:for-each>
</tr>
</table>
</xsl:template>
<xsl:template name="tokenize">
<xsl:param name="text" />
<xsl:param name="delimiter" select="'|'" />
<xsl:variable name="token" select="substring-before($text, $delimiter)" />
<item>
<xsl:value-of select="$token" />
</item>
<xsl:variable name="next" select="substring-after($text, $delimiter)" />
<xsl:if test="$next">
<!-- recursive call -->
<xsl:call-template name="tokenize">
<xsl:with-param name="text" select="$next" />
</xsl:call-template>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
解决方案
推荐阅读
- r - RJulia - 共享大型数据结构而不复制它们
- python - PyTorch - 在 NN 中有效地应用 TopK 梯度坐标
- node.js - 如何通过 puppeteer 拦截网站客户端生成的 blob 下载?
- cmake - CMake从生成器表达式中删除转义字符
- javascript - 不能在回调中调用 React Hook “useState”
- sql-server - 使 SSAS 模型保持最新的方法?
- c# - 当 Transfer-Encoding = chunked 时,如何增加可以部分请求的范围限制?
- excel - Excel 数据透视表中的相同/重复列名
- python-3.x - 如何将 .txt 文件中的字符串拆分为列表,从 AZ 排序且不重复?
- visual-studio - 如何使用 ifort 编译器运行 fortran 程序?