> The XQuery Processor
--timing, -t
Print timing information. In case of multiple queries the timing information is provided per each query
--output-file, -o
Write the result to the given file.
--serialize-html
Serialize the result as HTML.
--serialize-text
Serialize the result as Text.
--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 from the result.
--base-uri
Set the base URI property of the static context
--boundary-space
Set the boundary-space policy ('strip' or 'preserve') in the static context.
--default-collation
Add the given collation and set the value of the default collation in the static context to the given collation.
--construction-mode
Set the construction mode ('strip' or 'preserve') in the static context.
--ordering-mode
Set the ordering mode ('ordered' or 'unordered') in the static context
--multiple, -m
Execute the given queries multiple times.
--query, -q
Query test or file URI (file://...)
--as-files, -f
Treat all -q arguments as file paths instead of URIs or inline queries
--external-variable, -e
Provide the value for a variable given a file (name=file) or a value (name:=value)
--context-item
Set the context item to the XML document in a given file.
--optimization-level
Optimization level for the query compiler (O0 or O1)
-t, --print-query output options and -i execute option.Zorba command:
zorba -t --print-query -q "1+1" -q "fn:concat('un', 'grateful')" -q "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 -q comandline_doc_example_2.xq -q 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>