[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: why isn't there data-type for variable like sort?

Subject: RE: why isn't there data-type for variable like sort?
From: "Andrew Welch" <awelch@xxxxxxxxxxxxxxx>
Date: Wed, 20 Feb 2002 09:07:18 -0000
ms number xsl
>I have asked translations exponent number value like "4.8803077704e+06"
into decimal one within XSLT.
>At first, I tried number format="something" but failed. I think number
element is not the way for this task.

Hi Kang,

You can handle numbers like these using an MSXML4 extension function.  There
may be other ways, but if you have msxml4 then you can do this:

==xml==
<?xml version="1.0"?>
<root>
<number>4.8803077704e+06</number>
</root>

==xsl==
<xsl:stylesheet version="1.0"
                xmlns:ms="urn:schemas-microsoft-com:xslt"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">
  <xsl:apply-templates select="root/number"/>
</xsl:template>

<xsl:template match="number">
  <xsl:value-of select="ms:number(.)"/>
</xsl:template>

</xsl:stylesheet>

==html page==(to apply transformation)
<html>
<head>
  <script type="text/javascript">

  function applyXSL() {

    var xml = new ActiveXObject('MSXML2.DOMDocument.4.0');
    xml.async = false;
    xml.load('theXmlFile.xml');


    var xsl = new ActiveXObject('MSXML2.DOMDocument.4.0');
    xsl.async = false;
    xsl.load('theXslFile.xsl');

    document.write(xml.transformNode(xsl));

  }

  </script>

</head>

<body onload="javascript:applyXSL();">

</body>
</html>

==output==
4880307.7704


You will need to have msxml4 installed.  You can download this from:

http://www.msdn.microsoft.com/downloads/default.asp?url=/downloads/sample.as
p?url=/msdn-files/027/001/766/msdncompositedoc.xml

(all on one line)


Cheers

andrew

===



-----Original Message-----
From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
[mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Kang Jeong-Hee
Sent: Tuesday, February 19, 2002 11:36 PM
To: XSL-List@xxxxxxxxxxxxxxxxxxxxxx
Subject:  why isn't there data-type for variable like sort?


I have asked translations exponent number value like "4.8803077704e+06" into
decimal one within XSLT.
At first, I tried number format="something" but failed. I think number
element is not the way for this task.

I struggle to remember how I did handle the numbers on other languages. and
found that I need a type cast.
that's because XML handle all data only as string, not other one.

Is this right? IMHO variable have to support data-type attribute. but I
can't feel sure for my say. I'm newbie to XSL world.

well, Is there any way to translate 4.8803077704e+06 into decimal one?

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.