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"?>
<test>
<value>Hello World!</value>
<value>CHF -1'125.25</value>
<value>1'125.25</value>
<value>125.25</value>
<value>Hello World. Hello World. Hello World. Hello World. Hello World.
Hello World.</value>
</test>
Using modern XSLT/XPath I could achieve this with the following XSL using
regex:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:template match="test">
<table>
<tr>
<xsl:for-each select="value">
<td>
<xsl:choose>
<xsl:when test='matches(., ".*\.\d\d")'>
<nobr>
<xsl:value-of select="."/>
</nobr>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="."/>
</xsl:otherwise>
</xsl:choose>
</td>
</xsl:for-each>
</tr>
</table>
</xsl:template>
</xsl:stylesheet>
How could I achieve the same using old-fashioned string functions such as
substring and the like?
Marcel Stör
http://www.frightanic.com
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--