Hi, I am trying to copy attributes of one node to another:
copy $x := <test a="b" c="d"></test>, $y := parse-xml('<o a="x" c="y"></o>') modify ( delete nodes $x/@*, insert nodes $y/@* into $x ) return $x
Unfortunately, the resulting $x is an empty <test/> node. I expected it to have the attributes of the parsed node. Am I using parse-xml() properly?
Thanks!
Hi Erdal,
parse-xml() [1] returns a document-node, you need to get the root element. Try:
copy $x := <test a="b" c="d"></test>, $y := parse-xml('<o a="x" c="y"></o>') modify ( delete nodes $x/@*, insert node $y*/**/@* into $x ) return $x
/Andy [1] https://www.w3.org/TR/xpath-functions-30/#func-parse-xml
On 8 October 2016 at 18:28, Erdal Karaca erdal.karaca.de@gmail.com wrote:
Hi, I am trying to copy attributes of one node to another:
copy $x := <test a="b" c="d"></test>, $y := parse-xml('<o a="x" c="y"></o>') modify ( delete nodes $x/@*, insert nodes $y/@* into $x ) return $x
Unfortunately, the resulting $x is an empty <test/> node. I expected it to have the attributes of the parsed node. Am I using parse-xml() properly?
Thanks!
Thanks, Andy, that was it!
2016-10-08 21:36 GMT+02:00 Andy Bunce bunce.andy@gmail.com:
Hi Erdal,
parse-xml() [1] returns a document-node, you need to get the root element. Try:
copy $x := <test a="b" c="d"></test>, $y := parse-xml('<o a="x" c="y"></o>') modify ( delete nodes $x/@*, insert node $y*/**/@* into $x ) return $x
/Andy [1] https://www.w3.org/TR/xpath-functions-30/#func-parse-xml
On 8 October 2016 at 18:28, Erdal Karaca erdal.karaca.de@gmail.com wrote:
Hi, I am trying to copy attributes of one node to another:
copy $x := <test a="b" c="d"></test>, $y := parse-xml('<o a="x" c="y"></o>') modify ( delete nodes $x/@*, insert nodes $y/@* into $x ) return $x
Unfortunately, the resulting $x is an empty <test/> node. I expected it to have the attributes of the parsed node. Am I using parse-xml() properly?
Thanks!
basex-talk@mailman.uni-konstanz.de