xml - Renaming node with namespace -
hi have issue namespaces
my xml follows:
<earnings xmlns="http://www.dppvgu.com" currency="usd"> <distribution>15002111</distribution> <ticket_sales> <distribution num="2">24450144</distribution> <distribution num="3">12057133</distribution> </ticket_sales> <digital_sales> <ppv_sales>19220907</ppv_sales> <stream_sales>49725265</stream_sales> <disc_sales>15082021</disc_sales> </digital_sales> </earnings>
i rename node <distribution>15002111</distribution>
using following command:
for $doc in doc("earnings.xml")/*[local-name() = 'earnings']/*[local-name() = 'distribution'] return rename node $doc 'postbox'
i following error: [xudy0023] conflicts existing namespaces.
how resolve issue? please help
try using qname()
specify new name in default namespace :
for $doc in doc("earnings.xml")/*[local-name() = 'earnings']/*[local-name() = 'distribution'] return rename node $doc qname('http://www.dppvgu.com','postbox')
or using qname()
in combination namespace-uri()
avoid hardcoding namespace :
for $doc in doc("earnings.xml")/*[local-name() = 'earnings']/*[local-name() = 'distribution'] return rename node $doc qname(namespace-uri($doc),'postbox')
Comments
Post a Comment