[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl] String matching without regex

Subject: [xsl] String matching without regex
From: Marcel Stör <marcel@xxxxxxxxxxxxxx>
Date: Thu, 27 Jan 2005 06:58:45 +0100

Hi all,

For XML to HTML transformation I'd like to add the HTML <nobr> tag for each
table cell that contains currency values (or <td nowrap> as an alternative).
In my application currency values are values that always end with a .
followed by two digits.

[Test data]
<?xml version="1.0" encoding="UTF-8"?>
 <value>Hello World!</value>
 <value>CHF -1'125.25</value>
 <value>Hello World. Hello World. Hello World. Hello World. Hello World.
Hello World.</value>

Using modern XSLT/XPath I could achieve this with the following XSL using
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
 <xsl:template match="test">
       <xsl:for-each select="value">
       <xsl:when test='matches(., ".*\.\d\d")'>
         <xsl:value-of select="."/>
        <xsl:value-of select="."/>

How could I achieve the same using old-fashioned string functions such as
substring and the like?

Marcel Stvr

Current Thread