[xquery-talk] XQuery user defined function

Amitabh Ojha amitabhojha at rediffmail.com
Sun Mar 6 13:06:27 PST 2005

Dear Members,

This is about  difficulty I am experiencing in understanding  year 2001 style XQuery user defined function syntax. I am exposed to XQuery only since 2004. 

It is with reference to a year 2001 research paper which seeks to explain, how one might use XQuery to query Resource Description Frameworks. The XQuery user defined functions cited in that paper are appended below. Of course it is apparent that in 2001, the keywords "DEFINE FUNCTION" were used. The point I am unable to follow is, whether the datatypes of input and output parameters in those days were permitted to be any arbitrary user defined types (e.g "charstring", "statement", ListOfStatement" as in the cases appended below).  

If my understanding is correct, these days the datatypes of input/ output parameters of a user defined XQuery function are only allowed to be the generic datatypes as defined in XQuery Data Model - so that today one can't use such datatypes as "charstring", "statement", ListOfStatement" etc.  

I look forward to some clarification on this please.


Amitabh Ojha     

DEFINE FUNCTION element-to-triple(charstring $about, ELEMENT $s)
RETURNS statement

DEFINE FUNCTION attributes-to-triples(ELEMENT $about, ELEMENT $s)
RETURNS ListOfStatement
FOR $i IN $s/@*
WHERE not(name($i) = "rdf:about" or name($i) = "rdf:ID")
<subject>{ string($about) }</subject>
<predicate>{ name($i) }</predicate>
<object>{ string($i) }</object>

define function rdf:predicate-range(ListOfDescription $d, charstring $predicatename) RETURNS rdfs:range
$d[@rdf:about=$predicate-name and rdf:type="rdf:Property"]/rdfs:range
define function rdf:predicate-domain(ListOfDescription $d, charstring $predicatename)
RETURNS rdfs:domain
$d[@rdf:about=$predicate-name and rdf:type="rdf:Property"]/rdfs:domain

define function rdf:instance-of-class(ListOfDescription $t, charstring $basename) RETURNS ListOfDescription
$t[rdf:type = $base-name]
for $i in $t[rdfs:subClassOf = $base-name]
return rdf:instance-of-class($t, string($i/@rdf:about))
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://xquery.com/pipermail/talk/attachments/20050306/24daad7e/attachment.htm

More information about the talk mailing list