开发者

How do I use xsl format-number func. on an attribute?

开发者 https://www.devze.com 2023-04-10 16:38 出处:网络
I have a value I am parsing from an xml file that I need to stick into my table. I have the number displaying, but need to have it as \"#,###.0\" instead of just the integer. I got the number using:

I have a value I am parsing from an xml file that I need to stick into my table. I have the number displaying, but need to have it as "#,###.0" instead of just the integer. I got the number using:

<td><xsl:value-of select="amount/@pricePerUnit"/></开发者_JS百科td>

The price per unit is, let's say, 2. As I said, I need "2.0".

I have tried

<td><xsl:value-of select="amount/@format-number(pricePerUnit,'#,###.0')"/></td>

and

<td><xsl:value-of select="amount/format-number(@pricePerUnit,'#,###.0')"/></td>

but neither works. Have looked around with the googles, but can't seem to find the correct syntax. Can anyone help?


Try putting your xpath inside the function, as the first argument:

format-number(amount/@pricePerUnit, '#,###.0')

That'll find the value of your attribute node, pass it into the format-number() function, and give you back the return value.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号