Matching on Commas and Full Stops

Subject: Matching on Commas and Full Stops
From: Nigel Byrnes <byrnes@xxxxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 09 Feb 1999 11:27:04 +0000
Hi again all

When formating the contents of a text node, I want to achieve the sematics of the following regular expression:

s/([,\.])\s*/$1\n/g;

That is, on the occurance of a comma or fullstop, insert a line-feed (replacing any following whitespace). I have attempted (but
failed) to do achieve these semantics in xsl by the following:

<xsl:template match="contactAddress">
  <!-- this fails for two reasons: -->
  <!-- 1. The comma is an "unexpected token" -->
  <!-- 2. The fullstop/period is interpreted as the current node -->
  <xsl:if test=",|.">
    <xsl:apply-templates/>
    <BR></BR>
  </xsl:if>
</xsl:template>

<xsl:template match="contactAddress">
  <!-- Try and use XML entities -->
  <!-- Fails because XT believes these entities are undefined -->
  <xsl:if test="&comma; | &period;">
    <BR></BR>
    <xsl:apply-templates/>
  </xsl:if>
</xsl:template>

Does the answer lie in the functions defined in section 2.6.2 of the current XSL WD. Any ideas?

Thanks in advance

Nigel

--
      Nigel Byrnes

                               "We continue..." Pete Tong

Software Engineering and Applications Group,
Philips Research Labs,
Redhill.                           Tel: +44 (0)1293 815578
RH1 5HA.                           Fax: +44 (0)1293 815024
UK.                                GSM: +44 (0)7899 940391
                    Email: byrnes@xxxxxxxxxxxxxxxxxxxxxxxx



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread