Flow control


What a scripting language XSH would be had it not some kind of conditional statements, loops and other stuff that influences the way in which XSH commands are processed.

Most notable XSH's feature in this area is that some of the basic flow control statements, namely if, unless, while and foreach have two variants, an XPath-based one and a Perl-based one. The XPath-based variant uses xpath expressions to specify the condition or node-lists to iterate, while the other one utilizes perl-code for this purpose. See descriptions of the individual statements for more detail.

Related Argument Types and Commands

call
call user-defined routine (macro)
command-block
single XSH command or a block of XSH commands
def
sub-routine (macro) declaration
exit
exit XSH shell
foreach
loop iterating over a node-list or perl array
if
if statement
ifinclude
conditionally include another XSH source in current position
include
include another XSH source in current position
iterate
iterate a block over current subtree
last
immediately exit an enclosing loop
next
start the next iteration of an enclosing loop
prev
restart an iteration on a previous node
redo
restart the innermost enclosing loop block
return
return from a subroutine
run-mode
switch into normal execution mode (quit test-mode)
stream
process selected elements from an XML stream (EXPERIMENTAL)
test-mode
do not execute any command, only check the syntax
throw
throw an exception
try
try/catch statement
undef
undefine sub-routine (macro)
unless
negated if statement
while
simple while loop