XSLT 从 phone 数字中删除空格

XSLT remove spaces from phone number

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

    <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

您正在用 space 替换 space。 如果你总是想替换 spaces.

,我也不认为你需要条件
<xsl:value-of select="translate(EmployeeCellPhone, ' ', '')"/>

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