2.8. Declaration of variables, methods and types

Variables, methods, and types of values used in the script you can describe in the element <xd:declaration> in a X-Definition:
<xd:def xmlns:xd="http://www.xdef.org/xdef/4.2" name="Example" root="Measurements" >

<xd:declaration>
   int num = 0; /* Number of measurements. */
   float sum = 0.0; /* Sum of temperatures used for calculation of average. */
   /* Type of value of temperature (Celsius degree).*/
   type temperature double(-283.149806372, 10e4);
</xd:declaration>

<Measurements xd:script="finally printf('Number of measurements: %d, average: %2.1f%n', num, sum/num);" >
    <Temperature xd:script = "occurs +;">
      temperature(); onTrue { num++; sum += getParsedFloat(); };
    </Temperature>
</Measurements>

</xd:def>
You can try it HERE.