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

May 3rd, 2013, 06:37 AM
|
|
Authorized User
|
|
Join Date: Sep 2011
Posts: 12
Thanks: 1
Thanked 0 Times in 0 Posts
|
|
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.
|
|

May 3rd, 2013, 06:49 AM
|
|
Friend of Wrox
|
|
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
|
|
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:
|
|
|

May 3rd, 2013, 07:02 AM
|
 |
Wrox Author
|
|
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
|
|
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
|
|

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

May 3rd, 2013, 07:06 AM
|
|
Authorized User
|
|
Join Date: Sep 2011
Posts: 12
Thanks: 1
Thanked 0 Times in 0 Posts
|
|
Quote:
Originally Posted by mhkay
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 :)
|
|
 |