> The XQuery Processor
--version | Print program version. |
-h [ --help ] | Print the help list. |
-t [ --timing ] | Print timing information. In case of multiple queries the timing information if provided per each query. |
-o [ --output-file ] arg | Write the result to the given file. |
--serialize-html | Serialize the result as HTML. |
--indent | Indent output. |
--print-query | Print the queries. |
--byte-order-mark | Set the byte-order-mark for the serializer. |
--omit-xml-declaration | Omit the XML declaration. |
--base-uri arg | Specify the base URI property of the static context. |
--boundary-space arg | Sets the boundary-space policy in the static context. Values allowed are strip or preserve. |
--default-collation arg | Add the given collation and set the value of the default collation in the static context to the given collation. |
--construction-mode arg | Set the construction mode in the static context. Values allowed are strip or preserve. |
--ordering-mode arg | Set the ordering mode in the static context. Values allowed are ordered or unordered. |
-m [ --multiple ] arg | Execute the given queries multiple times. |
-i [ --inline ] arg | Inline the queries. All file options (-f) that are provided will be ignored. |
-f [ --file ] arg | Treat the arguments as files. In case inline option (-i) is provided, the file option is ignored. |
-e [ --external-variable ] arg | Provide the value for a variable given a file (name=file) or a value (name:=value). |
--context-item arg | Provide the context item given an XML document in a file. |
--optimization-level arg | Optimization level for compiling the query. Values allowed are O0, O1. |
-t, --print-query output options and -i execute option.Zorba command:
zorba -t --print-query -i "1+1" -i "fn:concat('un', 'grateful')" -i "fn:matches('abracadabra', '^a.*a$')"
Output:
Query number 1 :
1+1
<?xml version="1.0" encoding="UTF-8"?>
2
Number of executions = 1
Compilation time: 31 milliseconds
First Execution time: 0 milliseconds (i.e. parsing the document is included)
Query number 2 :
fn:concat('un', 'grateful')
<?xml version="1.0" encoding="UTF-8"?>
ungrateful
Number of executions = 1
Compilation time: 9 milliseconds
First Execution time: 0 milliseconds (i.e. parsing the document is included)
Query number 3 :
fn:matches('abracadabra', '^a.*a$')
<?xml version="1.0" encoding="UTF-8"?>
true
Number of executions = 1
Compilation time: 8 milliseconds
First Execution time: 0 milliseconds (i.e. parsing the document is included)
-f and -e execute options.These are the files used in this example and their meaning:
works-mod.xml | File that will be used as external variable. |
comandline_doc_example_2.xq | This is an update query. For details please see below. |
comandline_doc_example_2-test.xq | Query used to see the results of the update query. For details please see below. |
works-mod.xml :
<?xml version="1.0"?> <works> <employee name="Jane Doe 1" gender="female"> <empnum>E1</empnum> <pnum>P1</pnum> <hours>40</hours> </employee> <employee name = "John Doe 2" gender="male"> <empnum>E1</empnum> <pnum>P2</pnum> <hours>70</hours> <hours>20</hours>Text data from Employee[2] </employee> </works>
comandline_doc_example_2.xq :
(: Name: comandline_doc_example_2 :) (: Description: Evaluation of insert expression used with typeswitch expression where branch (a "case") is an updating expression. :) (: All other branches return "fn:error()". :) (: insert-start :) declare variable $input-context external; (: insert-end :) typeswitch(xs:int(1)) case $i as xs:int return (insert node <hours>30</hours> into $input-context/works[1]/employee[1]) case $i as xs:double return fn:error(fn:QName('http://www.w3.org/2005/xqt-errors', 'err:FOER0000')) default return fn:error(fn:QName('http://www.w3.org/2005/xqt-errors', 'err:FOER0000'))
comandline_doc_example_2-test.xq :
(: Name: comandline_doc_example_2-test :) (: Description: Query to verify comandline_doc_example_2 :) (: insert-start :) declare variable $input-context external; (: insert-end :) $input-context/works[1]/employee[1]
Zorba command:
zorba -e input-context=works-mod.xml -f comandline_doc_example_2.xq -f comandline_doc_example_2-test.xq
Make sure you give the correct path to the works-mod.xml, comandline_doc_example_2.xq and comandline_doc_example_2-test.xq files.
Expected result:
<employee name="Jane Doe 1" gender="female"> <empnum>E1</empnum> <pnum>P1</pnum> <hours>40</hours> <hours>30</hours></employee>