[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: String matching without regex

Subject: Re: String matching without regex
From: Jon Stockdill <jon.stockdill@xxxxxxxxx>
Date: Mon, 31 Jan 2005 07:11:50 -0500
jon stockdill
I am a newbie as well, but have found some good tools from the XSLT
Standard Library.
http://xsltsl.sourceforge.net/


On Fri, 28 Jan 2005 23:52:05 +0100, Marcel Stvr <marcel@xxxxxxxxxxxxxx>
wrote:
> Marcel Stvr <mailto:marcel@xxxxxxxxxxxxxx> wrote:
> > 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?
>
> This is a great list! Lots of posts and lots of helpful replies.
>
> I only wonder why my own post is the only unanswered posts for several
days.
> Did I not describe the problem in a way that should be easy to follow for
> everyone? Is the problem a too trivial one? Or is it too complicated;
rather
> not I would guess... Did I out of lack of experience break any of the rules
> of this mailing list?
>
> I'm just wondering...
> Marcel

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.