Hi Yann,

The common way to do this is as Martin proposed: You can strip
namespaces via a recursive function. See [1] for an example.

As this is a frequently asked feature, it would about time to define a
mode or built-in function for this purpose in BaseX. An equivalent
solution for exclude-result-prefixes could also be proposed for XQuery
4.0 [2]…

Salutations,
Christian

[1] 
https://www.mail-archive.com/[email protected]/msg13678.html
[2] https://github.com/qt4cg/qtspecs/issues




On Wed, Aug 25, 2021 at 5:54 PM Martin Honnen <[email protected]> wrote:
>
>
> 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.

Reply via email to