Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 30th, 2006, 09:24 AM
Registered User
 
Join Date: Oct 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default XPTY0004 on if-command position()

The code line below works correctly using an XSLT v1.0 engine but gives the following error when using an v2.0 engine...

XPTY0004: Cannot compare xs:integer to xs:string

<xsl:if test="position() = '35'"> <xsl:call-template name="Seq"></xsl:call-template></xsl:if>


Has anyone else experienced this ??
Thx

Ben


 
Old October 30th, 2006, 10:59 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

XSLT 2.0 has stronger typechecking. If you want to compare an integer to a string, you either have to convert the string to an integer or vice versa. In this case, write "position() = 35".

The reason for the change is to prevent some of the inconistencies taht arise in the 1.0 spec, for example in 1.0 if position() is 4, then

position() >= '004' returns true, but

position() = '004' returns false.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
get grandchildrens position() bonekrusher XSLT 2 March 19th, 2008 09:48 AM
Position barski XSLT 5 July 11th, 2007 01:54 PM
Command text was not set for the command object Sheraz Khan Classic ASP Databases 2 May 29th, 2007 12:57 AM
Command text was not set for the command object. deepa12 BOOK: Beginning ASP 3.0 5 November 2nd, 2004 05:37 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.