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

Re: problem with scientific notation and leading whit

Subject: Re: problem with scientific notation and leading whitespaces
From: Silvio Abruzzo <silvio.abruzzo@xxxxxxxxx>
Date: Thu, 18 Jul 2013 15:47:45 +0200
Re:  problem with scientific notation and leading  whit
Dear Ken,

Thank you for your prompt answer. Indeed, you solution works but I
would like to have a more general solution. The problem is that my
real xslt file has hundred of calculations and I cannot adapt all
places.

Kind Regards,
Silvio

On Thu, Jul 18, 2013 at 3:42 PM, G. Ken Holman
<gkholman@xxxxxxxxxxxxxxxxxxxx> wrote:
> Have you tried:
>
>   <xsl:value-of select="normalize-space( Apples * Bananas )"/>
>
> ... in which the expression is translated into a string and then the leading
> and trailing white-space characters are removed.
>
> I hope this helps.
>
> . . . . . . . Ken
>
>
> At 2013-07-18 15:34 +0200, Silvio Abruzzo wrote:
>>
>> Dear All,
>>
>> I have a problem with the following example
>>
>> $ cat testLarge.xml
>> <?xml version="1.0" encoding="utf-8"?>
>> <Refrigerator>
>>   <Apples>5000000000</Apples>
>>   <Bananas>10000000000000000</Bananas>
>> </Refrigerator>
>>
>> $ cat testSmall.xml
>> <?xml version="1.0" encoding="utf-8"?>
>> <Refrigerator>
>>   <Apples>5</Apples>
>>   <Bananas>10</Bananas>
>> </Refrigerator>
>>
>>
>> $ cat collect.xslt
>> <?xml version="1.0" encoding="UTF-8"?>
>> <xsl:stylesheet version="1.0"
>> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
>>     <xsl:output method="xml" indent="yes"/>
>>     <xsl:template match="Refrigerator">
>>       <xsl:value-of select="Apples * Bananas" />
>>     </xsl:template>
>> </xsl:stylesheet>
>>
>> $ xsltproc collect.xslt testLarge.xml
>> <?xml version="1.0"?>
>>  5e+25
>>
>> $ xsltproc collect.xslt testSmall.xml
>> <?xml version="1.0"?>
>> 50
>>
>> The problem that you may notice is that when I use testLarge.xml the
>> resulting value contains a leading whitespace, i.e. it is something
>> like " 5e+25". Instead, with small numbers I obtain "50" without
>> leading whitespace.
>>
>> Is this a bug? Should or could I configure something in order to not
>> have this problem? I would like to NOT have the leading whitespace.
>> Note that it is not acceptable to have a function which removes the
>> whitespace, the reason is that in my real xml file I have already
>> hundreds of fields and I cannot modify all of them by hand. It would
>> be acceptable a global solution.
>>
>> Here my data
>> $ xsltproc --version
>> Using libxml 20900, libxslt 10127 and libexslt 816
>> xsltproc was compiled against libxml 20900, libxslt 10127 and libexslt 816
>> libxslt 10127 was compiled against libxml 20900
>> libexslt 816 was compiled against libxml 20900
>>
>> Thank you very much for your answer.
>> Kind regards,
>> Silvio
>>
>> --
>> Abruzzo Silvio
>> silvio.abruzzo@xxxxxxxxx
>
>
>
> --
> Public XSLT, XSL-FO, and UBL classes in the Netherlands     Oct 2013 |
> Public XSLT, XSL-FO, UBL and code list classes in Australia Oct 2013 |
> Contact us for world-wide XML consulting and instructor-led training |
> Free 5-hour lecture: http://www.CraneSoftwrights.com/links/udemy.htm |
> Crane Softwrights Ltd.            http://www.CraneSoftwrights.com/s/ |
> G. Ken Holman                   mailto:gkholman@xxxxxxxxxxxxxxxxxxxx |
> Google+ profile: https://plus.google.com/116832879756988317389/about |
> Legal business disclaimers:    http://www.CraneSoftwrights.com/legal |
>



-- 
Abruzzo Silvio
silvio.abruzzo@xxxxxxxxx

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.