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

RE: functions with QName argument(s) in XPath

From: Parag Tijare <parag@almaden.ibm.com>
Date: Wed, 31 Aug 2005 17:31:30 -0700
To: www-ql@w3.org
Cc: mhk@mhk.me.uk
Message-ID: <OF1AE1A16B.07739883-ON8825706E.006082E6-8825706F.0002E291@us.ibm.com>





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



                                                                           
             "Michael Kay"                                                 
             <mhk@mhk.me.uk>                                               
             Sent by:                                                   To 
             www-ql-request@w3         "'Parag Tijare'"                    
             .org                      <parag@almaden.ibm.com>,            
                                       <www-ql@w3.org>                     
                                                                        cc 
             08/30/2005 03:28                                              
             PM                                                    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/



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)

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

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

Received on Thursday, 1 September 2005 00:33:11 UTC

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