Hi Christian,

Thanks! I’m using version 9.5. (I upgraded in case that solved things.)

To be clear, you’re comparing the stored documents "/test-ns/snippet.xml" and "/test-ns/workaround.xml", right? The results from update:output() should be fine.

Warmly,
Ash

From: Christian Grün <christian.gruen@gmail.com>
Sent: Friday, March 26, 2021 2:02 PM
To: Clark, Ash <as.clark@northeastern.edu>
Cc: basex-talk@mailman.uni-konstanz.de <basex-talk@mailman.uni-konstanz.de>
Subject: Re: [basex-talk] Missing namespaces when storing an excerpt?
 
Hi Ash,

Thanks for the reproducible example code.

On my system, the root elements of both $snippet and $workaround have
the 'https://nam12.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.w3.org%2F2005%2Fxpath-functions&amp;data=04%7C01%7Cas.clark%40northeastern.edu%7Cf1fb89b7dd5942b5de7608d8f0816087%7Ca8eec281aaa34daeac9b9a398b9215e7%7C0%7C0%7C637523785750125027%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=NNiAnkp7ayjQ5QNUyXKl5rugWBSCjrwwGOKU2vlB8O8%3D&amp;reserved=0' namespace (and
deep-equal($snippet, $workaround) yields true). Are you working with
the latest version of BaseX?

Cheers,
Christian


On Fri, Mar 26, 2021 at 6:53 PM Clark, Ash <as.clark@northeastern.edu> wrote:
>
> Hi!
>
> I’m pulling JSON from an API, converting the string to the XML representation, and storing part of the resulting XML into BaseX. The problem is, I can’t get the xmlns namespace declaration to stick to the XML excerpt once it’s saved to BaseX. It seems to work when I display the unstored excerpt.
>
> Here’s a short XQuery that illustrates my problem. Am I missing something? Is this a bug?
>
>
> xquery version "3.1";
>
> (:  NAMESPACES  :)
>   declare default element namespace "https://nam12.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.w3.org%2F2005%2Fxpath-functions&amp;data=04%7C01%7Cas.clark%40northeastern.edu%7Cf1fb89b7dd5942b5de7608d8f0816087%7Ca8eec281aaa34daeac9b9a398b9215e7%7C0%7C0%7C637523785750125027%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=NNiAnkp7ayjQ5QNUyXKl5rugWBSCjrwwGOKU2vlB8O8%3D&amp;reserved=0";
>   declare namespace db="https://nam12.safelinks.protection.outlook.com/?url=http%3A%2F%2Fbasex.org%2Fmodules%2Fdb&amp;data=04%7C01%7Cas.clark%40northeastern.edu%7Cf1fb89b7dd5942b5de7608d8f0816087%7Ca8eec281aaa34daeac9b9a398b9215e7%7C0%7C0%7C637523785750125027%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=DFp3e%2FG5fJRnDGPiVW6MJ1TivSgrUbi6u2%2F%2BmIq%2B%2B90%3D&amp;reserved=0";
>   declare namespace output="https://nam12.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.w3.org%2F2010%2Fxslt-xquery-serialization&amp;data=04%7C01%7Cas.clark%40northeastern.edu%7Cf1fb89b7dd5942b5de7608d8f0816087%7Ca8eec281aaa34daeac9b9a398b9215e7%7C0%7C0%7C637523785750125027%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=jQg422TqEiDRyIZW78hq5A9ZqBnBp0luX89Dh5AoGvI%3D&amp;reserved=0";
>   declare namespace update="https://nam12.safelinks.protection.outlook.com/?url=http%3A%2F%2Fbasex.org%2Fmodules%2Fupdate&amp;data=04%7C01%7Cas.clark%40northeastern.edu%7Cf1fb89b7dd5942b5de7608d8f0816087%7Ca8eec281aaa34daeac9b9a398b9215e7%7C0%7C0%7C637523785750125027%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=sSviqimFx6wpj%2FTTzvF%2BlF3O92jbHmDg3CUyP%2FA5Wj0%3D&amp;reserved=0";
> (:  OPTIONS  :)
>   declare option db:chop 'false';
>   declare option db:stripns 'false';
>   declare option output:indent 'yes';
>   declare option output:method 'xml';
>
> (:  MAIN QUERY  :)
>
> let $uri :=
>   "https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwwp.northeastern.edu%2Fexist%2Frest%2Fdb%2Fexhibits%2Fxquery%2Fpeople.xquery%3Ffile%3Dcaldwell.tenthmuse.xml&amp;data=04%7C01%7Cas.clark%40northeastern.edu%7Cf1fb89b7dd5942b5de7608d8f0816087%7Ca8eec281aaa34daeac9b9a398b9215e7%7C0%7C0%7C637523785750125027%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=kWqR84qP0C%2BSAM0Sr6KtyZQqs%2F%2F2dvcfeKMp1yYBu5g%3D&amp;reserved=0"
> let $full := json-to-xml(unparsed-text($uri))
> let $snippet := $full/fn:array/fn:map[1]
> let $workaround :=
>   <map xmlns="https://nam12.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.w3.org%2F2005%2Fxpath-functions&amp;data=04%7C01%7Cas.clark%40northeastern.edu%7Cf1fb89b7dd5942b5de7608d8f0816087%7Ca8eec281aaa34daeac9b9a398b9215e7%7C0%7C0%7C637523785750125027%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=NNiAnkp7ayjQ5QNUyXKl5rugWBSCjrwwGOKU2vlB8O8%3D&amp;reserved=0">{ $snippet/* }</map>
> return (
>     db:create("test-ns",
>               ($full, $snippet, $workaround),
>               ("full.xml", "snippet.xml", "workaround.xml")),
>     update:output(($snippet, $workaround))
>   )
>
>
> Thanks for your time!
>
> Warmly,
> Ash
>
> Ash Clark (my pronoun.is/e/em/eir)
> XML Applications Developer
> Digital Scholarship Group
> Northeastern University Libraries
> as.clark@northeastern.edu
> (617) 373-5983