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

Using '$' in function arguments

Subject: Using '$' in function arguments
From: "Martinez, Brian" <brian.martinez@xxxxxxxxxxx>
Date: Thu, 8 May 2003 14:50:32 -0600
xsl arguments escape
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

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.