Hello,

How to add/replace a complete node in a node tree,
with done by a function and by according function parameters.
That means with flexible instructions.

Such as:

declare function local:NodeAdd($XML, $XMLPath, $XMLValue)
{
  ??
};  

let $XML := <root><xml>text</xml></root>
let $XMLAdd := <B>BBB</B>
let $XMLPath := $XML/xml


return
  local:NodeAdd($XML, $XMLPath , $XMLAdd)

Problem:
Following examples didn't work, because an internal reference to copy-XML-structure is needed/forced.

example 1: copy / modify

declare function local:NodeAdd($XML, $XMLPath, $XMLValue)
{

  copy $XML2 := $XML
  modify (
    insert node $XMLValue  into $XML2/xml
  ) 
  return
  $XML2
};  

But: Instead of into $XML2/xml,

into $XML/xml is needed, respectively into $XMLPath


Thanks a lot
Michael