Kalinin
Kalinin

Reputation: 2519

Phone number transformation. Separate prefix in brackets

There is an element: <phone>(987) 123-45-67</phone>.

It is necessary to transform it in: <span><small>(987)</small>&#160;123-45-67</span>.

How it can be made?

Upvotes: 2

Views: 446

Answers (1)

Tomalak
Tomalak

Reputation: 338316

<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>

The above won't work for phone numbers in any different format than the one you show. Add some sanity checking of your own to ensure the phone number is in the format you expect.

Upvotes: 2

Related Questions