2016-11-18 3 views
1

BaseXのXquery関数でSVGタグのいくつかの属性を更新しようとしています。これまでは、1つの属性を更新して新しいノードを返しましたが、複数の属性は返しませんでした。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 
}; 

はその後、これを呼び出す:

<svg width="200" height="200"/> 

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

はこれを返します。

関連する問題