Am 25.08.2021 um 17:41 schrieb Yann NICOLAS (ABES):

Did you see my other suggestion in the first answer  to try to change your XQuery code to use

   insert node $record/c ! element { node-name() } {  @*, node() } into db:open('uk_parlement_ead')/dsc

Oh, i missed it ! Sorry.

It is working ... at the <c> level :

<c level="item">
  <did xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:marc="http://www.loc.gov/MARC21/slim">
   


I see, I guess one way would be to write a recursive function you pass that `c` element to that then recreates any element like in the above snippet, only recursively e.g.


declare function local:strip-namespaces($node as node()) as node()
{
    typeswitch($node)
      case element()
        return element { node-name($node) } { $node/@*, $node/node()!local:strip-namespaces(.) }
      default
        return $node

};


and then use e.g.


insert node $record/c ! local:strip-namespaces(.) into db:open('uk_parlement_ead')/dsc


Hopefully there is an easier way using XQuery update instructions but I am not good enough with them to know.