In: Computer Science
declare function prefix:function_name($parameter as
datatype?...)
as returnDatatype?
{
the body of the function comes here..
}
-->The expression can be showed as:
declare function local:discount($price as
xs:decimal?,$percentDiscount as xs:decimal?)
as xs:decimal? {
let $discount := $price - ($price * $percentDiscount div 100)
return $discount
};
let $originalPrice := 100
let $discountAvailed := 10
return ( local:discount($originalPrice, $discountAvailed))
--> Output for the above is => 90