2016-11-18 31 views
1

我想在BaseX的Xquery函数中更新SVG标记的几个属性。到目前为止,我设法更新一个属性并返回新节点,但不是多个属性。BaseX中多个属性更新

我试过多个更新作为声明here描述的变化,但无论我尝试它都不会工作。

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

上面的函数基本上是我想实现的。

回答

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"/>