Additions:
XML Expressions are expressions that construct or return XML [[http://www.w3.org/TR/xpath-datamodel/ XDM]] values including sequences.
For technical specifications of XQuery see [[http://www.w3.org/TR/xquery/ XQuery 1.0: An XML Query Language]]
XQuery 1.0 supports all the XQuery 1.0 and XPath 2.0 functions. See [[http://www.w3.org/TR/xpath-functions/ XQuery 1.0 and XPath 2.0 Functions and Operators]]
For technical specifications of XQuery see [[http://www.w3.org/TR/xquery/ XQuery 1.0: An XML Query Language]]
XQuery 1.0 supports all the XQuery 1.0 and XPath 2.0 functions. See [[http://www.w3.org/TR/xpath-functions/ XQuery 1.0 and XPath 2.0 Functions and Operators]]
Deletions:
No Differences
Additions:
xquery -q 'declare variable $A external; $A/foo' -n -v A $A
Deletions:
Additions:
For example to only pass in the A variable and use the same expression as above
xquery -q '$A/foo' -n -v A $A
xquery -q '$A/foo' -n -v A $A
Additions:
The generated xquery script for <[ $A/foo ]> looks like
$A/foo
$A/foo
Deletions:
[ user supplied xquery text ]
Additions:
===Parameters and Variables===
Positional parameters ($1 ... $N) and all environment variables with the XEXPR flag set are imported automatically.
Positional parameters are imported as variables named $_1 , $_2 ...
Environment variables are imported as their own name e,g $PATH, $TMPDIR
By default only variables assigned within xmlsh inherit the XEXPR flag. The intent is to avoid polluting the global namespace of the xquery expression, and to avoid unnecessary overhead.
The xml namespace is also predeclared and mapped to the XML extension functions.
Additionally all in scope namespaces are predeclared.
This is implemented by prepending a set of XQuery statements to every invocation of <[ ]>
For example suppose the environment contains the variables A and B with the XEXPR flag, and 2 positional parameters.
The generated xquery script looks like
%%(xquery)
declare namespace xmlsh="http://www.xmlsh.org/extfuncs";
[ additional in-scope namespace declarations ]
declare variable $A external ;
declare variable $B external ;
declare variable $_1 external ;
declare variable $_2 external ;
[ user supplied xquery text ]
The benefit of this is that shell variables, parameters, and namespaces are pre-declared with no additional syntax necessary.
However a side effect is that you cannot declare additional namespaces explicitly, or import modules, and there is some overhead
declaring and assigning variables which you may not use.
To have finer control over xquery execution use the [[CommandXQuery xquery]] command.
Positional parameters ($1 ... $N) and all environment variables with the XEXPR flag set are imported automatically.
Positional parameters are imported as variables named $_1 , $_2 ...
Environment variables are imported as their own name e,g $PATH, $TMPDIR
By default only variables assigned within xmlsh inherit the XEXPR flag. The intent is to avoid polluting the global namespace of the xquery expression, and to avoid unnecessary overhead.
The xml namespace is also predeclared and mapped to the XML extension functions.
Additionally all in scope namespaces are predeclared.
This is implemented by prepending a set of XQuery statements to every invocation of <[ ]>
For example suppose the environment contains the variables A and B with the XEXPR flag, and 2 positional parameters.
The generated xquery script looks like
%%(xquery)
declare namespace xmlsh="http://www.xmlsh.org/extfuncs";
[ additional in-scope namespace declarations ]
declare variable $A external ;
declare variable $B external ;
declare variable $_1 external ;
declare variable $_2 external ;
[ user supplied xquery text ]
The benefit of this is that shell variables, parameters, and namespaces are pre-declared with no additional syntax necessary.
However a side effect is that you cannot declare additional namespaces explicitly, or import modules, and there is some overhead
declaring and assigning variables which you may not use.
To have finer control over xquery execution use the [[CommandXQuery xquery]] command.
Additions:
----
[[CoreSyntax]]
[[CoreSyntax]]
Additions:
Entire XML documents stored in files can be read into variables using the [[CommandXread xread]] command.
Deletions:
Additions:
====Reading XML Documents====
Entire XML documents stored in files can be read into variables using the [[CommandsXread xread]] command.
Read an xml docment into variable a
xread a < file.xml
Entire XML documents stored in files can be read into variables using the [[CommandsXread xread]] command.
Read an xml docment into variable a
xread a < file.xml
Additions:
=====XML Process substition=====
Any command that produces an XML document (but not sequences > 1 value) can be evaulated using the $<( command )> syntax.
$ files=$<(xls)>
Any command that produces an XML document (but not sequences > 1 value) can be evaulated using the $<( command )> syntax.
$ files=$<(xls)>
Additions:
XML Expressions, like String expressions have access to environment variables.
$ A=string
$ B=<[<node/>]>
$ echo <[<element attr="{$A}">{$B}</element>]>
<element attr="string">
<node/>
</element>
$ A=string
$ B=<[<node/>]>
$ echo <[<element attr="{$A}">{$B}</element>]>
<element attr="string">
<node/>
</element>