[xsl] Using '$' in function arguments

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:


      <name>Extra Charges</rule-name>
      <line>Roll-away bed</line>
      <line>Amount of charge: $15.0</line>

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"
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.


| 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