I have a node with attributes and children.
<node attr1="value1" attr2="value2"><child1/><child2/></node>
I have a second node with a different set of attributes:
<node attr1="value1_new" attr3="value3_new"/>
I want to replace all attributes of the first node with the attributes from the second, preserving children. Missing attributes from the second node should be deleted. The desired result is:
<node attr1="value1_new" attr3="value3_new"><child1/><child2/></node>
This command will replace all contents of the node, thus removing children:
let $replacement = <node attr1="value1_new" attr3="value3_new"/>
replace node /node[1] with $replacement
How to update attributes and keep children?