【发布时间】:2013-07-07 11:10:48
【问题描述】:
我有一个 xsl 代码,我需要像在 Java 中那样实现 replaceAll 功能。我试过了 翻译功能,但它不起作用。我不确定在下面的代码中在哪里以及如何使用该函数,请您帮忙。
<xsl:template match="warning">
<xsl:param name="drugsSub" select="'false'"/>
<tr>
<td class="dataRowBorderBottom rowColor" style="width: 35%; padding-right: 5px; font-size:.85em;">
**<xsl:apply-templates select="translate(warningId,'/','/ ')">** This is not working. I want translate function to work both warningId. A value comes for this variable from some other file.
<xsl:with-param name="drugsSub" select="$drugsSub"/>
</xsl:apply-templates>
</td>
<td class="dataRowBorderBottom rowColor leftPadding" style="width: auto; padding-bottom: 15px; font-size:.85em;">
<xsl:apply-templates select="severity"/>
</td>
<td class="dataRowBorderBottom rowColor leftPadding" style="width: 13%;font-size:.85em;">
<xsl:apply-templates select="documentationRating"/>
</td>
<td class="dataRowBorderBottom rowColor leftPadding" style="width: 35%; padding-top: 3px; font-size:.85em;">
<xsl:value-of select="warningText"/>
</td>
</tr>
</xsl:template>
【问题讨论】:
-
请指定您想要发生的事情。样本输入和输出会很好。
translate()很可能没有按照您的想法去做。也许您正试图用字符串/替换每个/字符?如果是这样,最佳答案取决于您是否可以使用 XSLT 2.0,还是坚持使用 1.0。
标签: string xslt translate replaceall