1

我正在尝试在 BaseX 的 Xquery 函数中更新 SVG 标记的一些属性。到目前为止,我设法更新了一个属性并返回了新节点,但没有返回多个属性。

我尝试了多次更新作为此处描述的语句的变体,但无论我尝试了什么都行不通。

declare function  page:scaleSVG ($svg as node()*, $scale as xs:integer) as  node()* {
  return // update a few values of $svg attributes and return it
};

上面的功能基本上就是我想要实现的。

4

1 回答 1

1

使用复制/修改/返回结构。这是一个例子:

declare function page:scaleSVG ($svg as node()*, $scale as xs:integer) as  node()* {
copy $c := $svg
 modify (
    replace value of node $c/@width with $scale,
    replace value of node $c/@height with $scale 
 )
return $c
};

然后调用这个:

page:scaleSVG(<svg width="100" height="100" />, 200)

将返回这个:

<svg width="200" height="200"/>
于 2016-11-18T21:33:30.557 回答