【问题标题】:xsl - string translate in my code - Help requiredxsl - 我的代码中的字符串翻译 - 需要帮助
【发布时间】: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。
  • 这个问题是重复的:stackoverflow.com/questions/5280079/…

标签: string xslt translate replaceall


【解决方案1】:

我可以告诉你为什么代码不起作用: translate() 生成一个字符串,而你不能将模板应用于字符串(仅应用于节点集)。

但我不能告诉你如何解决它,因为我不知道你想要达到什么目的。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-29
    • 1970-01-01
    • 2020-12-20
    • 2018-05-13
    相关资源
    最近更新 更多