Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 3rd, 2013, 06:37 AM
Authorized User
 
Join Date: Sep 2011
Posts: 12
Thanks: 1
Thanked 0 Times in 0 Posts
Default XSLT variable path

Hi

I have xsl that get data from the Store Proc. below is one method of how get my values from the pro:

<xsl:value-of select="@Months" />

and I also fecth them in a "Path" method":

<xsl:value-of select="(//report/PolicyValue/row/@PortfolioValue)"/>

Now my problem is, I want to format the value that I return in the path e.g (<xsl:value-of select='format-number(AdvFeeTax, "###,###,##0.00")'/>)

I tried this:
<xsl:value-of select="(//report/MonthlyCharge/row/'format-number(@ChargePercentage, ""###,###,##0.00"")' )"/>

and I'm getting an error. please help.
 
Old May 3rd, 2013, 06:49 AM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

Well with XSLT 2.0 you have two options, the first is with a single node you use
Code:
format-number(//report/MonthlyCharge/row/@ChargePercentage, "###,###,##0.00")
the second allows you to call the function for each node in a sequence
Code:
//report/MonthlyCharge/row/format-number(@ChargePercentage, "###,###,##0.00")
With XSLT 1.0 you only have the first option.
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog
The Following User Says Thank You to Martin Honnen For This Useful Post:
stahorse (May 3rd, 2013)
 
Old May 3rd, 2013, 07:02 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

When you get an error, it's always important to tell us what the error is. You might not understand it, but we probably do.

I think it's most likely that the error is because your path expression selects more than one node, and format-number can only process one node on each call. Are you trying to format many numbers, or only one?
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
 
Old May 3rd, 2013, 07:04 AM
Authorized User
 
Join Date: Sep 2011
Posts: 12
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Thank You :) it works now.
 
Old May 3rd, 2013, 07:06 AM
Authorized User
 
Join Date: Sep 2011
Posts: 12
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by mhkay View Post
When you get an error, it's always important to tell us what the error is. You might not understand it, but we probably do.

I think it's most likely that the error is because your path expression selects more than one node, and format-number can only process one node on each call. Are you trying to format many numbers, or only one?
Yes I thought of mentioning my error but as again that it will be clear that my path wrong, need to be coded right. otherwise I always mention the error that I get.

Thanks :)





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to use variable in path? Shinji XSLT 2 September 18th, 2008 09:08 AM
assign XSLT variable to a wml variable arunagottimukkala XSLT 2 October 19th, 2007 05:15 AM
value from a xml path in a variable ?? TPP XSLT 2 June 23rd, 2006 03:11 AM
Appending to PATH environment variable jacob C# 1 February 9th, 2004 10:43 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.