xsl-list
[Top] [All Lists]

Using '$' in function arguments

2003-05-08 13:50:32
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(_dot_)martinez(_at_)cendant(_dot_)com |
| 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



<Prev in Thread] Current Thread [Next in Thread>