Document Developer - instructions > XPath > Variable arrays

Variable arrays
A variable array returns an indexed node set of values. Each node also has an @index attribute:
Example 50
$array[0] = "A";
$array[1] = "B";
stEvalXPath("$array[0]") //returns empty string
stEvalXPath("$array[1]") //returns A
stEvalXPath("$array[2]") //returns B
 
An index attribute is generated for array nodes in the following form, where different index levels are comma-separated:
@index = "L1[,L2[...,Ln]]"
The index values are 0-based.
Note:
$array[1] is a shortcut for $array[position()=1]
Example 51
$array[0] = "A";
$array[1] = "B";
The following script function will return A:
stEvalXPath("$array[@index=0]")
The following script function will return B:
stEvalXPath("$array[@index=1]")
 
Example 52
$field[0][0] = "A0"; 
$field[0][1] = "A1";
$field[1][0] = "B0";
$field[1][1] = "B1";
stEvalXPath("$field") //returns A0
stEvalXPath("$field[1]") //returns A0
stEvalXPath("$field[2]") //returns A1
stEvalXPath("$field[last()]") //returns B1
stEvalXPath("$field[@index=’1,0’]") //returns B1
---
A Repeater defined for the $field returns a node-set with values (A0,A1,B0,B1).
 
Note:
A node-set returned from an array includes only values that are defined. If the array has undefined values in it, those are not included.
OpenText StreamServe 5.6.2 Updated: 2018-01-26