【问题标题】:Phone number transformation. Separate prefix in brackets电话号码转换。括号中的单独前缀
【发布时间】:2011-02-07 19:41:01
【问题描述】:

有一个元素:<phone>(987) 123-45-67</phone>

需要转换成:<span><small>(987)</small> 123-45-67</span>

如何制作?

【问题讨论】:

    标签: xslt textnode


    【解决方案1】:
    <span>
      <small>
        <xsl:value-of select="concat(substring-before(phone, ')'), ')')" />
      </small>
      <xsl:text>&#160;</xsl:text>
      <xsl:value-of select="normalize-space(substring-after(phone, ')'))" />
    </span>
    

    以上内容不适用于与您显示的格式不同的电话号码。添加您自己的一些健全性检查,以确保电话号码采用您期望的格式。

    【讨论】:

    • @Tomalak,谢谢。只有&lt;xsl:value-of select="normalize-space(substring-after(phone, ')')" /&gt; 必须是&lt;xsl:value-of select="normalize-space(substring-after(name, ')'))" /&gt; 的行中没有右括号。有用!谢谢。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-01-05
    • 1970-01-01
    • 2021-08-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多