Subject: Re: [xsl] problem with scientific notation and leading whitespaces From: Michael Kay <mike@xxxxxxxxxxxx> Date: Thu, 18 Jul 2013 15:11:20 +0100 |
The output, on the evidence supplied, does not conform to either the XSLT 1.0 or 2.0 specification. In 1.0 numbers should never be displayed in scientific notation. In 2.0, there should not be any whitespace added. So you should raise this as a bug (non-conformance) with whoever (if anyone) supports xsltproc. If there's a workaround, that's where you're likely to find out about it. Alternatively, switch to a different processor. Michael Kay Saxonica On 18 Jul 2013, at 14:34, 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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] problem with scientific n, G. Ken Holman | Thread | Re: [xsl] OT: Discount on XSL Cours, G. Ken Holman |
Re: [xsl] problem with scientific n, G. Ken Holman | Date | [xsl] OT: Discount on XSL Course, Rick Quatro |
Month |