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/
 
 


  _____  

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

Received on Tuesday, 30 August 2005 22:28:43 UTC