| Subject: [xsl] Using '$' in function arguments From: "Martinez, Brian" <brian.martinez@xxxxxxxxxxx> Date: Thu, 8 May 2003 14:50:32 -0600 | 
One of my team members just ran into an interesting problem.  He's trying to
use substring-after() to pull a number from XML input to format it as a
currency amount:
XML:
<hotel-rate>
  <rate-rules>
    <rule>
      <name>Extra Charges</rule-name>
      <line>Roll-away bed</line>
      <line>Amount of charge: $15.0</line>
    </rule>
  </rate-rules>
</hotel-rate>
The problem is the number in the "Amount" line; it needs to be reformatted
to read "15.00".  So he tried:
<xsl:variable name="extra-charge"
select="substring-after(hotel-rate/rate-rules/rule[name='Extra
Charges']/line[contains(.,'Amount of')], 'Amount of charge: $')"/>
<xsl:value-of select="format-number($extra-charge,'$#.00')"/>
The error seems to lie in the use of $ inside the search string argument for
substring-after().  My only guess is that the processor (Xalan 2.5.something
in this case) thinks it's a variable reference, but it shouldn't be treated
as one when inside a literal string, correct?  At any rate, if anyone has an
idea how to escape this (or if you can think of a better way to write the
above) I would appreciate it.
thanks,
b.
| brian martinez                           brian.martinez@xxxxxxxxxxx |
| lead gui programmer                                    303.708.7248 |
| cheap tickets, part of trip network                fax 303.790.9350 |
| 6436 s. racine cir.                             englewood, co 80111 |
| cendant travel distribution services   http://www.cheaptickets.com/ |
 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
| Current Thread | 
|---|
| 
 | 
| <- Previous | Index | Next -> | 
|---|---|---|
| RE: Re: [xsl] Scope of variables, cknell | Thread | RE: [xsl] Using '$' in function arg, Michael Kay | 
| Re: [xsl] Scope of variables, Mike Haarman | Date | RE: [xsl] Scope of variables, Martinez, Brian | 
| Month |