Hi, I am relatively new to baseX and XQuery and just trying the funcionalities of BaseX. I have got some questions on the possibility of defining user-defined functions, which take a node (or a node set) as parameters and process them subsequently (e.g. format the results as an html table, or another numerical computations etc.).
This might look like this:
define function createTable($n as node) { for $c in $n/* return <some html-output>; }
and I would like to use the defined function "createTable" in a xquery expression. For example :
for $questionscheme in doc("database")//d:QuestionScheme return createTable($questionscheme/node())
That means I need to pass a whole node (not the query results as string), in order to process the node with further xquery expressions. Is this compatible with BaseX? And where should I define such functions? Defining a function through the XQuery-API does not work. The functions in class Query in the BaseXClient.php seem to only support a successive query processing (one result tuple after another). Or have I overseen something? If not, can this class be quickly modified to support this?
Many thanks for your help on this!
Johanna,
specifying nodes as arguments is straight-forward in XQuery; this expression might do what you want:
declare function local:createTable($n as node()) as node()* { for $c in $n/* return <result/> }; for $node in doc("database")//node return local:createTable($node)
Hope this helps, Christian
On Tue, Jul 13, 2010 at 3:02 PM, johanna.vompras@uni-bielefeld.de wrote:
Hi, I am relatively new to baseX and XQuery and just trying the funcionalities of BaseX. I have got some questions on the possibility of defining user-defined functions, which take a node (or a node set) as parameters and process them subsequently (e.g. format the results as an html table, or another numerical computations etc.).
This might look like this:
define function createTable($n as node) { for $c in $n/* return <some html-output>; }
and I would like to use the defined function "createTable" in a xquery expression. For example :
for $questionscheme in doc("database")//d:QuestionScheme return createTable($questionscheme/node())
That means I need to pass a whole node (not the query results as string), in order to process the node with further xquery expressions. Is this compatible with BaseX? And where should I define such functions? Defining a function through the XQuery-API does not work. The functions in class Query in the BaseXClient.php seem to only support a successive query processing (one result tuple after another). Or have I overseen something? If not, can this class be quickly modified to support this?
Many thanks for your help on this!
BaseX-Talk mailing list BaseX-Talk@mailman.uni-konstanz.de https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
basex-talk@mailman.uni-konstanz.de