问题 To mimic an auto-increment value in XQuery Update, the following works fine, assuming <root count="0"/> when running this for the first time: let $count := /root/@count return ( insert node <node id='{ $count }'/> into /root, replace value of node $count with $count + 1 ) ...nicely yielding: <root count="1"> <node id="0"> </root> However, I'd like to define the node in my Java code, and then bind that as an org.w3c.dom.Node or Document , or even String . Like: String expr = " declare variable