Revision [1330]

Last edited on 2010-04-17 17:24:10 by DavidLee
Additions:
See Also [[BuiltinVariables Builtin Variables]]


Revision [1068]

Edited on 2009-11-29 08:38:58 by DavidLee
Additions:
See Also [[BasicSyntax Basic Syntax]]
See Also [[CommandTie tie]]
Deletions:
See Also [[BasicSyntax]]
See Also [[CommandTie]]


Revision [1067]

Edited on 2009-11-29 08:38:39 by DavidLee
Additions:
====Tied Variables====
See the [[CommandTie tie]] command for how to tie xquery expressions to variables.
See Also [[BasicSyntax]]
See Also [[CommandTie]]
Deletions:
See Also [[BasicSyntax]]


Revision [1066]

Edited on 2009-11-29 08:37:58 by DavidLee
Additions:
====Sequence Append====
Sequences can be appended using the syntax
VAR+=value
This is a syntax shortcut for
VAR=($VAR,value)
or
VAR=<[ $VAR , value ]>
If the variable doesn't exist it is created as if assigned using =.
Example: Create a sequence of integers 1 to 10 then append 20 to 30
A=<[ 1 to 10 ]>
A+=<[ 20 to 30 ]>
echo $A
Result
1 2 3 4 5 6 7 8 9 10 20 21 22 23 24 25 26 27 28 29 30
Example Create an element then append to it
A=<[ <foo>text</foo> ]>
A+=<[ <bar>text</bar> ]>
xecho $A
Result
%%(xml)
<foo>text</foo>
<bar>text</bar>


Revision [805]

Edited on 2009-09-23 10:45:34 by DavidLee
Additions:
Note that this is different then non-sequence construction which doesn't do globbing (wildcard expansion).
Deletions:
Note that this is different then non-sequence construction which doesnt do globbing (wildcard expansion).


Revision [626]

Edited on 2009-06-13 16:55:56 by DavidLee
Additions:
var=()
echo <[count($var)]>
returns
var=""
echo <[count($var)]>
Returns
====Array Notation====
xmlsh supports a simplified version of the bash array notation in variable expansion.
The expression ${variable[index]} expands to the index'd element of a sequence variable. Index starts at 1 for compatibility with xpath expressions. ${variable[index]} is equivalent to <[ $variable[index] ]>.
The expression ${#variable} expands to the sequence length of variable. ${#variable} is equivalent to <[ count($variable) ]>
A non-sequenced variable is equivalent to a sequenced variable of length 1.
Unlike bash, sparse arrays are not supported because array notation is just a syntactic simplification over the XML infoset sequence variables which cannot be sparse.
Examples
var=(foo bar spam)
echo ${#var}
echo ${var[2]}
returns
3
bar
var=<[ "foo" , <spam attr="bar"><bletch>text</bletch></spam> , 1 , 2 , 3 ]>
echo ${#var}
xecho ${var[2]}
returns
5
<spam attr="bar"><bletch>text</bletch></spam>
Deletions:
$ var=()
$ echo <[count($var)]>
$ var=""
$ echo <[count($var)]>


Revision [428]

Edited on 2009-03-11 05:43:05 by DavidLee
Additions:
Assuming there are 21 xml files in the current directory
$ echo <[ count($var) ]>
21
$ var=*.xml
$ echo <[ count($var) ]>


Revision [427]

Edited on 2009-03-11 04:39:09 by DavidLee
Additions:
====Sequence Construction====
Variable assignment supports a simplified sequence expression, similar to bash and ksh array assignment.
var=(elem elem ...)
For example
$ var=(foo bar spam)
Assigns an XML sequence of strings equivilent to
$ var=<[("foo","bar","spam")]>
The values inside () are expanded using Word expansion and Globbing before being assigned.
Note that this is different then non-sequence construction which doesnt do globbing (wildcard expansion).
$ var=(*.xml)
Assigns var to be the sequence containing all xml files in the current directory.
The empty sequence construct creates an empty sequence. This is different then string assignment which creates a empty string.
$ var=()
$ echo <[count($var)]>
0
$ var=""
$ echo <[count($var)]>
1


Revision [246]

Edited on 2008-07-04 11:25:47 by DavidLee
Additions:
Variables are created using variable assignment ([[Variables]]). The type of the expression determins
Deletions:
Variables are created using variable assignment (CommandAssignVariable). The type of the expression determins


Revision [245]

Edited on 2008-07-04 11:25:27 by DavidLee
Additions:

----
See Also [[BasicSyntax]]


Revision [227]

Edited on 2008-06-12 17:07:53 by DavidLee
Additions:
E=$(ls)
A=$<(xls)
Deletions:
A=$<(xls)>


Revision [101]

Edited on 2008-04-22 16:49:39 by DavidLee
Additions:
C=${B}
D=$(echo yet more strings)
Deletions:
C=$(echo yet more strings)


Revision [100]

Edited on 2008-04-22 16:49:00 by DavidLee
Additions:
DOC=<[<foo><bar>text</bar></foo>]>
T=<[<spam>{$DOC//bar}</spam>]>


Revision [99]

The oldest known version of this page was created on 2008-04-22 16:47:05 by DavidLee
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki