Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3398322
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T04:38:07+00:00 2026-05-18T04:38:07+00:00

Hello Am a beginner to XSL hardly know few commands. I was trying out

  • 0

Hello
Am a beginner to XSL hardly know few commands.
I was trying out a sample where i have to format a number based on the entry in the XML.
I want to use the format-number function to achieve the same.

<Details>
<Order>Bulk Order</Order>
<OrderDate>1997-07-16T19:20:30+01:00</OrderDate>
<Quantity>100</Quantity>
<Price>99.45</Price>
<Format>de_DE</Format>
</Details>


<Details>
<Order>Bulk Order</Order>
<OrderDate>1997-07-16T19:20:30+01:00</OrderDate>
<Quantity>100</Quantity>
<Price>99.45</Price>
<Format>en_US</Format>
</Details>

However i can render the output if i use :

<xsl:value-of select='format-number(500100, "###,###.00")' />

But i want to use a certain condition

i.e if the Format is de_DE :
I want to pass the ###.###,00 to format-number method (note the decimal and thousand separators)
or if the Format is en_US
I want to pass the ###,###.00 to format-number method

I hopeless tried using choose statement ( but i really have no idea about the syntax of usage)

<xslt:choose>
    <xslt:when test="$format = 'de_DE'">###,###.00</xslt:when>
    <xslt:when test="$format = 'en_US'">###.###,00</xslt:when>
    <xslt:otherwise>###.###,00</xslt:otherwise>
</xslt:choose>

Can anyone help me to put this onto a template or something so that i just call

and i get the output based on the format present in the XML

Thanks
Srivatsa

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T04:38:08+00:00Added an answer on May 18, 2026 at 4:38 am

    You could apply-templates and match on the value of the text node as follows:

    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    
    
    <xsl:template match="/">        
        <xsl:apply-templates select="/root/Details"/>
    </xsl:template>
    
    <xsl:template match="Details">      
    
        <xsl:variable name="total" select="Price * Quantity"/>
    
        <xsl:apply-templates select="Format">
            <xsl:with-param name="total" select="$total"/>
        </xsl:apply-templates>
    
    </xsl:template>
    
    <xsl:template match="Format[text()='de_DE']">
        <xsl:param name="total"/>       
        <xsl:value-of select="format-number($total, '###.###.00')"/>
    </xsl:template>
    
    <xsl:template match="Format[text()='en_US']">
        <xsl:param name="total"/>       
        <xsl:value-of select="format-number($total, '###,###.00')"/>
    </xsl:template>
    

    This code for example, matches all Details nodes and for each match gets the total for the order. It then does an apply-template on the format passing in the total as a parameter. The match then occurs on the value of the format node.

    I think the format ‘###.###.00’ is invalid as it seems that only one decimal point is allowed. ‘###,###.00’ is fine.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi this is ROR beginner's question. I have creat controller.rb and view hello.rhtml following
hello i am beginner in developing ndk apps. I was going to build sample
I'm a complete beginner in JS, so pls have patience :) my.hello = function
Hello I am a lua beginner and am trying to loop through a CSV
hello i am a beginner in objective-c i have a nsstring like this Select
Hello people I'm trying to figured this out, but I still can't do it.
Hello I'm a Django Beginner. I have a calendar that I want to be
Hello I have strange problem. I configured spring + hibernate. I`m using annotation configuration
Hello I am new to the Objective C and I have a problem. I
hello all i have one json object like {event1:{title:My birthday,start:12\/27\/2011 10:20 ,end:12\/27\/2011 00:00 },event2:{title:My

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.