RE: [xsl] error using number()

Subject: RE: [xsl] error using number()
From: Mike Ferrando <mikeferrando@xxxxxxxxx>
Date: Fri, 14 May 2004 12:45:25 -0700 (PDT)
Michael,
Ok. I thought this might be the problem. I need to use number() on
the string only. When I did that, it worked fine.

I took a look at the number() in your first edition. I gathered that
the function must be used purely and not mixed with other opperands.

However, I regularly write the following:

number($x + 7)

This has not given me any errors and passed by fine in SAXON 7.

Mike Ferrando
Washington, DC

--- Michael Kay <mhk@xxxxxxxxx> wrote:
> > I am getting this error.
> > 
> > When I run my stylesheet with SAXON instant 6.5.3, everything
> runs
> > fine without errors. But my friend ran the same stylesheet with
> his
> > SAXON 7 and received this error (below).
> > 
> > Is there some reason why the error only comes up with the SAXON
> 7?
> 
> Rather than 
> 
> number(substring(A,B,C) - 1000)
> 
> you need to write
> 
> number(substring(A,B,C)) - 1000
> 
> Generally, XPath 2.0 is stricter about type checking than 1.0
> (though if you
> specify version="1.0" in the xsl:stylesheet element then most
> things revert
> to the 1.0 rules). If you want to use a string as an arithmetic
> operand, you
> now have to convert it to a number explicitly. This change allows
> operators
> to be overloaded to do different things with different data types.
> 
> Michael Kay
> 
> 
> > 
> > Mike Ferrando
> > Washington, DC
> > 
> > 
> > Error returned:
> > 
> > bash-2.05b$  java -jar c:/saxon79/saxon7.jar -o ead.html
> > fa_2002_8859_1_x.xml c:/my_ead_2002_conv/ead_2002_HTML_conv-1.xsl
> 
> > Error at variable st_p-sb on line 2280 of
> > file:/c:/my_ead_2002_conv/ead_2002_HTML_conv-1.xsl:
> >   Unsuitable operands for arithmetic operation (xs:string,
> > xs:integer)
> > Transformation failed: Run-time errors were reported
> > 
> > XSL
> > 
> > 	<xsl:variable name="st_p-sb" 
> > select="number(substring($physdesc_b,
> > string-length($physdesc_b) -9, 4) - 1000)"/>
> > 
> > 
> > 
> > --- B Tommie Usdin <btusdin@xxxxxxxxxxxxxxxx> wrote:
> > > My goodness - such a lot of blood from such a small cut!
> > > 
> > > This announcement seems to have done something remarkable: at
> least
> > > for a moment in one forum it seems to have erased all concerns
> > > about XSLT 2.0 and rallied EVERYONE to it's defense.
> > > 
> > > How odd: until we saw this I heard quite a few concerns about
> > > XSLT 2.0 and have had several conversations with developers I
> > > respect who said that they were thinking of sticking with
> > > XSLT 1.0 because the gains in 2.0 (for their applications) were
> > > not worth the losses.  Now all of a sudden non-adoption of
> > > XSLT 2.0 is "killing xslt".
> > > 
> > > 
> > > Perhaps the folks at Microsoft were concerned that they would
> be
> > > criticized for adopting a controversial spec like XSLT 2.0 so
> they
> > > decided to rally support for it by announcing that they were
> not
> > > going to support it. Then they could change their minds and be
> > > heros instead of goats. ... Nahhhh. But it sounds good.
> > > 
> > > -- Tommie
> > > -- 
> > >
> >
>
======================================================================
> > > B. Tommie Usdin                       
> > > mailto:btusdin@xxxxxxxxxxxxxxxx
> > > Mulberry Technologies, Inc.               
> > > http://www.mulberrytech.com
> > > 17 West Jefferson Street                           Phone:
> > > 301/315-9631
> > > Suite 207                                    Direct Line:
> > > 301/315-9634
> > > Rockville, MD  20850                                 Fax:
> > > 301/315-8285
> > >
> >
>
----------------------------------------------------------------------
> > >    Mulberry Technologies: A Consultancy Specializing in  XML
> and
> > > SGML
> > >
> >
>
======================================================================
> > > 
> > 
> > 
> > 
> > 	
> > 		
> > __________________________________
> > Do you Yahoo!?
> > SBC Yahoo! - Internet access at a great low price.
> > http://promo.yahoo.com/sbc/
> 



	
		
__________________________________
Do you Yahoo!?
SBC Yahoo! - Internet access at a great low price.
http://promo.yahoo.com/sbc/

Current Thread