Trying to use xslt to move the decimal and remove the extra 0s

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jonathan184
    New Member
    • Nov 2006
    • 154

    Trying to use xslt to move the decimal and remove the extra 0s

    Hi so I have these 2 values in the incoming xml

    <Value1>1800000 </Value1>
    <Value>385000 </Value>

    I am trying to transform this format to the following
    <DATA>180.00</DATA>
    <DATA>38.50</DATA>

    I attempted to use the following
    <xsl:decimal-format name="dollars" decimal-separator="." grouping-separator=","/>

    <xsl:value-of select="format-number(OrderQua ntity/Quantity/Number/Value1,'###.### ##', 'dollars')"/>

    <xsl:value-of select="format-number(OrderQua ntity/Quantity/Number/Value,'###.#### #', 'dollars')"/>

    I tried different combinations with the hash but no luck.
    Any help would be greatly appreciated.
  • Luuk
    Recognized Expert Top Contributor
    • Mar 2012
    • 1043

    #2
    "trying to move the decimal"
    that sounds like "dividing by 10"

    something (untested, because I do know nothing about XSLT
    Code:
    <xsl:value-of select="format-number(OrderQuantity/Quantity/Number/Value div 10000,'###.#####', 'dollars')"/>

    Comment

    • jonathan184
      New Member
      • Nov 2006
      • 154

      #3
      That helped i was only thinking of using the built in function with the decimals. That was a good idea and it worked. Thanks

      Code:
      <xsl:value-of select="format-number(GrossPrice/MonetaryValue/Number/Value div 10000., '0.00')"/>

      Comment

      Working...