Revision [1061]
This is an old revision of CommandXquery made by DavidLee on 2009-11-27 03:53:55.
Command xquery
Name
xquery evaluate an XQUERY expression and print the resultSynopsis
xquery [ serialization options ] [-f xquery-file] [-v] [-q xquery-expr] [-i input-file] [-n] [-nons] [-ns prefix=uri [-ns prefix=uri ...] [xquery-expr] [var value [var value]] [-s]Description
-f xquery-file | read xquery script from file |
-i context | use context as the source xml document, otherwise stdin if context is an XML expression which is an item then use it directly as the context item. |
-q query | use argument as xquery-expr |
-n | do not use a source context |
-v | if -V is given then the remaining args are treated as name/value pairs and assigned to xquery external variables |
-nons | Do not import global namespace declarations from the shell environment |
-ns prefix=uri | Add a predeclared namespace declaration |
-s -strring | convert every node value in the result to a string |
xquery-expr xquery expression
Supports the standard [ serialization options ]
If no -q or -f is given then the next argument is treated as the xquery expression/script.
Not all options are compatible. You cannot read both the query and the context from stdin.
If you supply variables then -q must be supplied.
If the result (or any node of the result if a sequence) is an Attribute, or if the -s option is specified the it is converted to a string.
Example
xls | xquery '//file[1]/@name/string()'
Result
.classpath
Simplified example, you dont need string()
xls | xquery '//file[1]/@name'
Result
.classpath
Example
xquery -i <[<foo/>] .
Result
<foo/>
Namespace example using a renamed prefix for a namespace
echo "<x:a xmlns:x='foo' />" | xquery -nons -ns y=foo /y:a
Result
<x:a xmlns:x="foo"/>
Return Value
Returns 0 if the the xquery expression executed successfully. otherwise 1Commands
CategoryCommands