|
||||||||||||||||||||||
|
|
The xquery accessor executes xquery scripts. The xquery script is provided through the operator. The resulting document is returned to the target. This xquery implementation uses the LGPL Qexo XQuery implementation on the Kawa engine. Xqueries are serialized and compiled to native bytecode before execution in the Kawa runtime. In order to provide access to resources passed from the dexter runtime platform we provide access to the operand and parameter documents in the xquery script. These can be loaded with the xquery document() operation as operand.xml and param.xml respectively. Here is an example of loading the operand into a variable in the xquery script: <xquery>
let $operand := document("operand.xml")/PLAY/ACT[1]/SCENE[1]
return <SPEECHES> {$operand//SPEECH[SPEAKER='GLOUCESTER']} </SPEECHES>
</xquery>
XQuery can be used for processing/querying the operand/param documents. It can also be used as a generative scripting language for dynamically creating documents with or without reference to the operand and param documents. Operator SyntaxThe xquery accessor requires an xquery script. The xquery script is passed in by the operator in an <xquery> document. <xquery>
<table>{
for $y in 1 to 10 return (
<tr>{
for $x in 1 to 10 return
let $bg:=(if($x mod 2 + $y mod 2 <= 0) then "lightgreen"
else if ($y mod 2 <= 0) then "yellow"
else if ($x mod 2 <= 0) then "lightblue"
else "white"),
$prod:=$x*$y
return <td align="right" bgcolor="{$bg}">{
if ($x > 1 and $y > 1) then $prod else <b>{$prod}</b>}</td>
}</tr>,
"
")
}</table>,"
"
</xquery>
<xquery> contains an escaped xquery script for execution by the xquery engine. Note it is important that all xml symbols such as angle brackets <, >, are escaped. Example
(C) 2003, 1060 Research Limited |
|||||||||||||||||||||
|
© 2003,2004, 1060® Research Limited
1060 registered trademark, NetKernel trademark of 1060 Research Limited
|
||||||||||||||||||||||