Skip to content

[BUG] Storing with parse-xml-fragment adds unnecessary xmlns prefixes #5790

@lguariento

Description

@lguariento

Though not specifically a bug, this issue is more like of a nuisance which would be good if addressed.

Describe the bug
When storing a node containing sub-nodes, the latter will get a prefix and a xmlns added, even if the parent node is in the correct xmlns.

Expected behavior
It'd be good if, instead, the sub-nodes had no xmlns or prefixes (if they're supposed to be on the same namespace of the parent of course).

To Reproduce

xquery version "3.1";

declare namespace tei = "http://www.tei-c.org/ns/1.0";

declare variable $base-tei-doc := document {
    <listPerson xmlns="http://www.tei-c.org/ns/1.0">
        <person xml:id="1">
            <persName>
                <surname>Ozzy</surname>
                <forename>Osbourne</forename>
            </persName>
        </person>
    </listPerson>
};

declare variable $note-content-1 := document { <hi>testing1</hi> };
declare variable $note-content-2 := parse-xml-fragment("<hi>testing1</hi>");
declare variable $note-content-3 := document { <hi xmlns='http://www.tei-c.org/ns/1.0'>testing2</hi> };
declare variable $note-content-4 := parse-xml-fragment("<hi xmlns='http://www.tei-c.org/ns/1.0'>testing2</hi>");

let $stored-doc := xmldb:store("/db", "example1.xml", $base-tei-doc)
return
    let $list-person := doc($stored-doc)/tei:listPerson
    
    let $person-record := 
        <person xmlns="http://www.tei-c.org/ns/1.0">
            <persName>
                <surname>Zakk</surname>
                <forename>Wylde</forename>
                <note>{$note-content-1}</note>
                <note>{$note-content-2}</note>
                <note>{$note-content-3}</note>
                <note>{$note-content-4}</note>
            </persName>
        </person>
    
    return
        update insert $person-record into $list-person

This produces /db/example1.xml:

<listPerson xmlns="http://www.tei-c.org/ns/1.0">
    <person xml:id="1">
        <persName>
            <surname>Ozzy</surname>
            <forename>Osbourne</forename>
        </persName>
    </person>
    <person>
        <persName>
            <surname>Zakk</surname>
            <forename>Wylde</forename>
            <note>
                <hi xmlns="">testing1</hi>
            </note>
            <note>
                <hi xmlns="">testing1</hi>
            </note>
            <note>
                <hi>testing2</hi>
            </note>
            <note>
                <tei:hi xmlns:tei="http://www.tei-c.org/ns/1.0">testing2</tei:hi>
            </note>
        </persName>
    </person>
</listPerson>

Context (please always complete the following information)

eXist-6.4.0
openjdk 17.0.15 2025-04-15
OpenJDK Runtime Environment (build 17.0.15+6-Debian-1deb12u1)
OpenJDK 64-Bit Server VM (build 17.0.15+6-Debian-1deb12u1, mixed mode, sharing)
Linux Debian 12.11

Additional context
JAR installation

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions