W3C home > Mailing lists > Public > www-ql@w3.org > July to September 2005

RE: functions with QName argument(s) in XPath

From: Michael Kay <mhk@mhk.me.uk>
Date: Fri, 2 Sep 2005 00:14:28 +0100
To: <www-ql@w3.org>
Message-ID: <E1EAyGT-0005H0-Si@lisa.w3.org>
You can pass QNames around at run-time that contain the names of types, but
there's nothing useful you can do with them, any more than you can do
anything meaningful with a variable holding the string "int" or "long" in C.
XQuery is not currently a reflexive language.
 
Michael Kay
http://www.saxonica.com/


  _____  

From: Parag Tijare [mailto:parag@almaden.ibm.com] 
Sent: 01 September 2005 01:32
To: www-ql@w3.org
Cc: mhk@mhk.me.uk
Subject: RE: functions with QName argument(s) in XPath



Thanks for the reply - it is very helpful.
> in XPath: you can't pass a type to a function, nor return a type from a
function.

Is it possible to pass the QName of the type, using the mechanisms you
indicated below and use these to achieve "type sensitive behavior" from the
function. Would that violate XPath in any way?

Thanks,
Parag Tijare

Inactive hide details for "Michael Kay" <mhk@mhk.me.uk>"Michael Kay"
<mhk@mhk.me.uk>






	"Michael Kay" <mhk@mhk.me.uk> 
Sent by: www-ql-request@w3.org 

	08/30/2005 03:28 PM




To

"'Parag Tijare'" <parag@almaden.ibm.com>, <www-ql@w3.org>	



cc

	



Subject

RE: functions with QName argument(s) in XPath	
	 	

XPath does not have a QName literal. If function F takes a QName as its
argument, then you can call it as, for example

F(node-name($n))

or

F(QName("uri", "local"))

or

F(resolve-QName("xsi:type", .))

but you can't call it as

F(app:type1)

except in the special case where evaluating the path expression app:type1
and atomizing the result gives you a QName.

An element test is a special construct for a number of reasons, one of which
is that types are not first class objects in XPath: you can't pass a type to
a function, nor return a type from a function.

Michael Kay
 <http://www.saxonica.com/> http://www.saxonica.com/




  _____  

From: www-ql-request@w3.org [mailto:www-ql-request@w3.org] On Behalf Of
Parag Tijare
Sent: 30 August 2005 22:09
To: www-ql@w3.org
Subject: functions with QName argument(s) in XPath


Is it possible to define an XPath function that takes type name or node name
as arguments, something along the lines of "Element Test" (which is a
built-in construct) in XPath.

If yes, wouldn't there be a conflict in interpreting the argument? 

e.g. consider a hypothetical function "foo" that is intended to take a type
name as its second argument.
in /A/B/foo(C, myapp:Type1), would XPath semantics require that the second
argument be interpreted as being the child node of /A/B rather than a type
name?
I wonder if "Element Test" is designed as a built-in construct rather than a
function for this reason.

Any ideas?

Thanks,
Parag Tijare 









graycol.gif
(image/gif attachment: graycol.gif)

ecblank.gif
(image/gif attachment: ecblank.gif)

Received on Thursday, 1 September 2005 23:14:43 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 20:17:17 UTC