Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1370
  • Last Modified:

Format currency xslt

I need to do 2 things
1. add the trialing zero to a price
I have tried this but it is having no affect
 <xsl:value-of select="format-number(yahoo:Price, '#,00')"/>

2 i need to prefix the price with £ but xsl doesnt like it, i have also tried &pound; but it doesnt like that either.

how can i prefix the price with £

Thank you
0
QuinnDester
Asked:
QuinnDester
  • 6
  • 5
1 Solution
 
Geert BormansCommented:
2.
&#163;
will give you no problem,

1.
Can you show the XML and say what exactly you want?
could be
<xsl:value-of select="format-number(yahoo:Price, '#.00')"/>
maybe it isn't numeric, because of the ',' in your source
0
 
QuinnDesterAuthor Commented:
found the error for 1. Gertone.
most are numeric but some have a string in them EG. not available.

how can i check its a numeric value and apply the formating accordingly
0
 
QuinnDesterAuthor Commented:
for number 2 i get this £11,79

the £ sign is there but i also have an A with a hat on :)
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
Geert BormansCommented:
a test for number could be
not(string(number(.)) = 'NaN')
0
 
Geert BormansCommented:
&#163;
should always result in a pound signe, without the Â
If you see the  in front of it, it means that some process thinks it is ISO-Latin 1 instead of UTF-8
but some process in between is in error,
how to you execute the XSLT?
0
 
QuinnDesterAuthor Commented:
at the moment i am using xmlspy, i havnt tried it in the application yet, ill give that a go now
0
 
QuinnDesterAuthor Commented:
Thanks Gertone, directly in the application it works fine, it must be an xmlspy thing

I have tried this to test for the number but i am shooting in the dark for the syntax, can you point out where i am going wrong.

            <xsl:choose>
      
            <xsl:when test="not(string(yahoo:DeliveryCost(.)) = 'NaN')">
                &#163;<xsl:value-of select="format-number(yahoo:DeliveryCost, '#.00')"/>
                </xsl:when>
                <xsl:otherwise>
                <xsl:value-of select="yahoo:DeliveryCost"/>
                </xsl:otherwise>
</xsl:choose>
0
 
Geert BormansCommented:
XML Spy doing stupid things.. that is no surprise :-)
0
 
Geert BormansCommented:
If I were you, I would wrap the pound sign in a xsl:text element
<xsl:text>&#163;</xsl:text>
you will get rid of possible erroneous white-space, if you do so

about your problem, the test should be
<xsl:when test="not(string(number(yahoo:DeliveryCost)) = 'NaN')">
0
 
QuinnDesterAuthor Commented:
brilliant thank you Gertone

i tried this and it does work but doesnt recoginise 0 as a number,

<xsl:when test="number(yahoo:DeliveryCost)">

your way gets everything thank you

and i will start rapping text in <text></text> thank you for the advice
0
 
Geert BormansCommented:
welcome
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 6
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now