Subject: Re: [xsl] questions on "number('+5')" From: Hermann Stamm-Wilbrandt <STAMMW@xxxxxxxxxx> Date: Mon, 30 Aug 2010 19:54:38 +0200 |
> It depends a bit on the syntax you want to accept and the error checking > you want to perform. For many purposes, number(translate($str, '+','')) > would work adequately. Thanks, "number(translate($str, '+',''))" is better since it lets number() function deal with whitespace. Mit besten Gruessen / Best wishes, Hermann Stamm-Wilbrandt Developer, XML Compiler, L3 WebSphere DataPower SOA Appliances ---------------------------------------------------------------------- IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Martin Jetter Geschaeftsfuehrung: Dirk Wittkopp Sitz der Gesellschaft: Boeblingen Registergericht: Amtsgericht Stuttgart, HRB 243294 From: Michael Kay <mike@xxxxxxxxxxxx> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Date: 08/30/2010 07:44 PM Subject: Re: [xsl] questions on "number('+5')" > So "number('+5')" should result in NaN. In XSLT 1.0, yes, it should. In XSLT 2.0 it should result in the integer 5. > Here is the result of "number('+5')" for different XSLT processors: > Chrome NaN > DataPower NaN > Firefox NaN > IE NaN > Opera 5 > Safari NaN > saxon 5 > xalan 5 > xsltproc NaN Saxon 9.x correctly reports the result 5. Saxon 6.5.5 correctly reports the result NaN. > > Two questions: > 1) Is it true that XSLT processors returning 5 are non-compliant? They are non-compliant with XSLT 1.0, yes. > 2) Is the following a good workaround? > > <xsl:variable name="str" select="'+5'"/> > <xsl:value-of select="number(substring($str,1+starts-with($node,'+')))"/> > It depends a bit on the syntax you want to accept and the error checking you want to perform. For many purposes, number(translate($str, '+','')) would work adequately. Michael Kay Saxonica
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] questions on "number('+5', Michael Kay | Thread | [xsl] Error XSLT 1.0 (xsltproc), pankaj . c |
Re: [xsl] questions on "number('+5', Michael Kay | Date | Re: Fw: [xsl] Question on duplicate, Hermann Stamm-Wilbra |
Month |