result
Syntax
result expression;
result { /* body */ }
Description
Define the return value for a function. The value can be a simple scalar value, an XML element or XPath expression, or a set of instructions that emit the value to be returned.
Attributes
result expression |
XPath expression defining the return value of the function. |
SLAX Example
The following example defines three extension functions, my:size()
, my:box-parts()
, and my:ark()
. The my:ark()
function returns a node set containing an <ark>
element that encloses the node set returned by the my:box-parts()
function. The my:box-parts()
function returns a node set containing a <box>
element enclosing three <part>
child
elements. The content of each <part>
element is the value returned by the my:size()
function. The return value of the my:size()
function is the product of the three parameters width
, height
, and scale
.
version 1.1; ns my exclude = "http://www.example.com/myfunctions"; function my:size ($x, $y, $scale = 1) { result $x * $y * $scale; } function my:box-parts ($width, $height, $depth, $scale = 1) { result <box> { <part count=2> my:size($width, $depth); <part count=2> my:size($width, $height); <part count=2> my:size($depth, $height); } } function my:ark () { result { <ark> { copy-of my:box-parts(2.5, 1.5, 1.5); } } } match / { var $res = my:ark(); copy-of $res; }
Release Information
Statement introduced in version 1.1 of the SLAX language, which is supported in Junos OS Release 12.2 and later releases.