Hi Christian thank you for your input.
> The problem is that your original document > uses the default namespace "http://www.mygym.com", and your query uses > "http://www.gym.com". In other words, the error is raised because the > namespace binding of your target name conflicts with the existing > namespace binding. That I don’t get. This works let $i:=(doc("FitnessCenter.xml")//Name)[1] return rename node $i as QName('http://www.gym.com', "Name”) with <?xml version="1.0" encoding="UTF-8”?> <FitnessCenter> <Member Level="platinum"> <Name>Jeff</Name> <FavoriteColor>lightgrey</FavoriteColor> </Member> </FitnessCenter> This not declare namespace gym='http://www.mygym.com'; let $i:=(doc("FitnessCenter.xml")//gym:Name)[1] return rename node $i as QName('http://www.gym.com', "Name”) with <?xml version="1.0" encoding="UTF-8”?> <FitnessCenter xmlns="http://www.mygym.com"> <Member Level="platinum"> <Name>Jeff</Name> <FavoriteColor>lightgrey</FavoriteColor> </Member> </FitnessCenter> Why should that conflict? Always Leo > > Here is a recursive approach to change the default namespace of a document: > ______________________________________ > > declare function local:update($root as node(), $ns as xs:string) { > if($root instance of element()) then ( > element { QName($ns, local-name($root)) } { > $root/@*, > for $node in $root/node() > return local:update($node, $ns) > } > ) else ( > $root > ) > }; > > let $ns := 'http://www.gym.com' > let $root := doc("FitnessCenter.xml")/* > let $updated := local:update($root, $ns) > return replace node $root with $updated > ______________________________________ > > Hope this helps, > Christian > > > > On Tue, Sep 16, 2014 at 12:10 PM, Leo Studer <[email protected]> wrote: >> Hello >> >> I use the following query with Saxon-EE xQuery 9.5.1.5 in Oxygen. >> >> for $i in doc('FitnessCenter.xml')//* >> return rename node $i as QName('http://www.gym.com', local-name($i)) >> >> >> on the following file: >> >> <?xml version="1.0" encoding="UTF-8"?> >> <FitnessCenter xmlns="http://www.mygym.com"> >> <Member Level="platinum"> >> <Name>Jeff</Name> >> <FavoriteColor>lightgrey</FavoriteColor> >> </Member> >> <Member Level="gold"> >> <Name>David</Name> >> <FavoriteColor>lightblue</FavoriteColor> >> </Member> >> </FitnessCenter> >> >> and get the following error: new name conflicts with existing namespace >> binding >> >> >> I thought the function local-name() produces an output without namespace >> binding? Can anyone explain? >> >> Thanks in advance >> Leo >> >> >> _______________________________________________ >> [email protected] >> http://x-query.com/mailman/listinfo/talk _______________________________________________ [email protected] http://x-query.com/mailman/listinfo/talk
