XML Support

XML can be typed in directly in a DSQL script, or via the <data> element.

Parameters

The following attributes can be set in the <data> element.

Name Value Description
type 'xml'  
file 'inline', or file name document to parse
url URL document to parse
root element or path parsing starts at the given element
encoding encoding name the character encoding
parser Java class name The parser to use; default is 'dsql.parser.Parser' (DSQL parser)
eval_var 'true' or 'false' Evaluate variables inside contents and attributes; default 'true' for inline, 'false' for external

Accessing elements

This is done with the dot ('.') syntax. Examples...

Reading long documents

External documents are parsed 'on demand', i.e. more elements are read when they are requested. In the example below, file "myfile.xml" is not parsed and loaded entirely in memory, but rather one element at a time.

foreach my $ele <data file="myfile.xml"/>
  if($ele.status = 'active') print $ele;

This example assumes the enumerated elements are direct children of the document root. When this is not the case, the root attribute can be used to specify a starting path.

Variable evaluation

When used inline, variables and <dsql> elements are evaluated. Examples...

$currentStaff = <staff><firstname>$fname</firsname> </staff>