declare %an:sequential function local:image(
$id as xs:string, $width as xs:int*,
$height as xs:int*, $ratio as xs:decimal*, $format as xs:string) as xs:base64Binary
{
variable $obj := null;
if (fn:empty($obj)) then
()
else
{
variable $svg := $obj("svg");
if (fn:not(jn:is-null($obj("size")("width")))) then
{
variable $svg-width := $obj("size")("width");
variable $svg-height := $obj("size")("height");
if ($width) then
{ $svg-height := xs:int(($svg-height div $svg-width) * $width);
$svg-width := $width;
}
else if ($height) then
{
$svg-width := xs:int(($svg-width div $svg-height) * $height); $svg-height := $height;
}
else if ($ratio) then
{
$svg-width := xs:int($svg-width * $ratio); $svg-height := xs:int($svg-height * $ratio);
}
else
{}
$svg := <a>{$svg}</a>/*;
replace value of node $svg/@width width xs:string($svg-width) || "px";
replace value of node $svg/@height width xs:string($svg-height) || "px";
}
else
{}
}
};
Query:
=====
declare %an:sequential function local:image(
$id as xs:string, $width as xs:int*,
$height as xs:int*, $ratio as xs:decimal*, $format as xs:string) as xs:base64Binary
{
variable $obj := null;
if (fn:empty($obj)) then jn:is-null( $obj("size" )("width" )))) then )("width" ); )("height" );
()
else
{
variable $svg := $obj("svg");
if (fn:not(
{
variable $svg-width := $obj("size"
variable $svg-height := $obj("size"
if ($width) then
$svg- height := xs:int(($svg-height div $svg-width) * $width);
$svg- height := $height;
$svg- height := xs:int($svg-height * $ratio);
{
$svg-width := $width;
}
else if ($height) then
{
$svg-width := xs:int(($svg-width div $svg-height) * $height);
}
else if ($ratio) then
{
$svg-width := xs:int($svg-width * $ratio);
}
else
{}
$svg := <a>{$svg}</a>/*;
replace value of node $svg/@width width xs:string( $svg-width) || "px"; $svg-height) || "px";
replace value of node $svg/@height width xs:string(
}
else
{}
}
};
Error Msg: dagraf/ work/28msec/ zorba/build/ test.xq> :7,22: static error [err:XPST0003]: invalid expression: syntax error, unexpected ExprSingle (missing comma "," between expressions?); raised at /Users/ dagraf/ work/28msec/ zorba/sandbox/ src/compiler/ api/compiler_ api.cpp: 197
========
</Users/
Actual Problem:
============
replace expressions contain a typo: s/width/with