【问题标题】:XSLT remove spaces from phone numberXSLT 删除电话号码中的空格
【发布时间】:2020-06-19 15:51:56
【问题描述】:

我正在尝试格式化字符串以从电话号码中删除空格,但遇到了问题。我使用的代码是:

    <xsl:choose>
      <xsl:when test="EmployeeCellPhone != ''">
        <xsl:value-of select="translate(EmployeeCellPhone, ' ',' ')"/>
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="translate(EmployeeHomePhone, ' ',' ')"/>
      </xsl:otherwise>
    </xsl:choose>

但是,它不起作用。谁能指出我正确的方向?当前输出看起来像这样:123 456 7890,我需要结果看起来像:1234567890

【问题讨论】:

  • 需要去掉第三个arg中的空格...translate(EmployeeHomePhone,' ','')
  • 成功了,谢谢@DanielHaley

标签: xslt xslt-1.0


【解决方案1】:

您正在用空格替换空格。 如果您总是想替换空格,我也认为您不需要条件。

<xsl:value-of select="translate(EmployeeCellPhone, ' ', '')"/>

在这里看到它的工作:https://xsltfiddle.liberty-development.net/naZYrpC

【讨论】:

    猜你喜欢
    • 2020-10-07
    • 1970-01-01
    • 2020-09-07
    • 2020-03-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-02-12
    • 1970-01-01
    相关资源
    最近更新 更多