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 22nd, 2006, 11:49 AM
Registered User
 
Join Date: Oct 2006
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default context-item returns...?

I have doubts about using the . (dot)

Is it safe or correct to say:
 test=". = $page" //$page as xs:integer

Or should I put it like this?:
 test="xs:integer(.) = $page"

Another example:
 test=". = $stringVar" | test="./text() = $stringVar"
 | test="xs:string(.) = $stringVar"



 
Old October 22nd, 2006, 12:09 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

It depends what "." is. I assume because you're using functions like xs:integer(.) you're asking about XPath 2.0. If "." is an untyped node, then ". = 2" will atomize the node to give an untypedAtomic value, and will then convert both values to doubles to do the comparison. This will work if the node has the value "2.0" (giving true) or "2.5" (giving false). On the other hand xs:integer(.) = 2 will fail if the value is "2.0" or "2.5", because these can't be converted to integers.

Generally, with schemaless data, untyped nodes will be converted automatically to the required type and you only need to do explicit conversions in special cases, for example if you really do want integer arithmetic rather than double arithmetic.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old October 22nd, 2006, 09:29 PM
Registered User
 
Join Date: Oct 2006
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks very much Sir Michael Kay, I am not worthy of your response :-)






Similar Threads
Thread Thread Starter Forum Replies Last Post
ReadProcessMemory returns nothing evolution445 Visual Basic 2005 Basics 17 October 8th, 2008 07:56 AM
Unable to set context in web.xml or context.xml. dchicks Apache Tomcat 1 March 7th, 2008 07:59 AM
Not all code returns a value Doom C# 4 February 11th, 2008 03:48 PM
Want Combo Box first item if only 1 item markw707 Access 3 June 9th, 2004 04:03 PM
Find Out First Item of each item Group Jane SQL Language 1 November 22nd, 2003 12:42 PM





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