Missing namespaces when storing an excerpt?
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 "http://www.w3.org/2005/xpath-functions";
declare namespace db="http://basex.org/modules/db";
declare namespace output="http://www.w3.org/2010/xslt-xquery-serialization";
declare namespace update="http://basex.org/modules/update";
(: 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://wwp.northeastern.edu/exist/rest/db/exhibits/xquery/people.xquery?file=caldwell.tenthmuse.xml"
let $full := json-to-xml(unparsed-text($uri))
let $snippet := $full/fn:array/fn:map[1]
let $workaround :=
<map xmlns="http://www.w3.org/2005/xpath-functions">{ $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<http://pronoun.is/e/em/eir>) XML Applications Developer Digital Scholarship Group Northeastern University Libraries as.clark at northeastern.edu (617) 373-5983
Hi Ash,
Thanks for the reproducible example code.
On my system, the root elements of both $snippet and $workaround have the 'http://www.w3.org/2005/xpath-functions' namespace (and deep-equal($snippet, $workaround) yields true). Are you working with the latest version of BaseX?
Cheers, Christian
Quoted text · Ash · 49 lines
On Fri, Mar 26, 2021 at 6:53 PM Clark, Ash <as.clark at 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 "http://www.w3.org/2005/xpath-functions"; > declare namespace db="http://basex.org/modules/db"; > declare namespace output="http://www.w3.org/2010/xslt-xquery-serialization"; > declare namespace update="http://basex.org/modules/update"; > (: 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://wwp.northeastern.edu/exist/rest/db/exhibits/xquery/people.xquery?file=caldwell.tenthmuse.xml" > let $full := json-to-xml(unparsed-text($uri)) > let $snippet := $full/fn:array/fn:map[1] > let $workaround := > <map xmlns="http://www.w3.org/2005/xpath-functions">{ $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 at northeastern.edu > (617) 373-5983
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
Quoted text · Christian Grün · 62 lines
From: Christian Grün <christian.gruen at gmail.com> Sent: Friday, March 26, 2021 2:02 PM To: Clark, Ash <as.clark at northeastern.edu> Cc: basex-talk at mailman.uni-konstanz.de <basex-talk at 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&data=04%7C01%7Cas.clark%40northeastern.edu%7Cf1fb89b7dd5942b5de7608d8f0816087%7Ca8eec281aaa34daeac9b9a398b9215e7%7C0%7C0%7C637523785750125027%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=NNiAnkp7ayjQ5QNUyXKl5rugWBSCjrwwGOKU2vlB8O8%3D&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 at 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&data=04%7C01%7Cas.clark%40northeastern.edu%7Cf1fb89b7dd5942b5de7608d8f0816087%7Ca8eec281aaa34daeac9b9a398b9215e7%7C0%7C0%7C637523785750125027%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=NNiAnkp7ayjQ5QNUyXKl5rugWBSCjrwwGOKU2vlB8O8%3D&reserved=0"; > declare namespace db="https://nam12.safelinks.protection.outlook.com/?url=http%3A%2F%2Fbasex.org%2Fmodules%2Fdb&data=04%7C01%7Cas.clark%40northeastern.edu%7Cf1fb89b7dd5942b5de7608d8f0816087%7Ca8eec281aaa34daeac9b9a398b9215e7%7C0%7C0%7C637523785750125027%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=DFp3e%2FG5fJRnDGPiVW6MJ1TivSgrUbi6u2%2F%2BmIq%2B%2B90%3D&reserved=0"; > declare namespace output="https://nam12.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.w3.org%2F2010%2Fxslt-xquery-serialization&data=04%7C01%7Cas.clark%40northeastern.edu%7Cf1fb89b7dd5942b5de7608d8f0816087%7Ca8eec281aaa34daeac9b9a398b9215e7%7C0%7C0%7C637523785750125027%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=jQg422TqEiDRyIZW78hq5A9ZqBnBp0luX89Dh5AoGvI%3D&reserved=0"; > declare namespace update="https://nam12.safelinks.protection.outlook.com/?url=http%3A%2F%2Fbasex.org%2Fmodules%2Fupdate&data=04%7C01%7Cas.clark%40northeastern.edu%7Cf1fb89b7dd5942b5de7608d8f0816087%7Ca8eec281aaa34daeac9b9a398b9215e7%7C0%7C0%7C637523785750125027%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=sSviqimFx6wpj%2FTTzvF%2BlF3O92jbHmDg3CUyP%2FA5Wj0%3D&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&data=04%7C01%7Cas.clark%40northeastern.edu%7Cf1fb89b7dd5942b5de7608d8f0816087%7Ca8eec281aaa34daeac9b9a398b9215e7%7C0%7C0%7C637523785750125027%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=kWqR84qP0C%2BSAM0Sr6KtyZQqs%2F%2F2dvcfeKMp1yYBu5g%3D&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&data=04%7C01%7Cas.clark%40northeastern.edu%7Cf1fb89b7dd5942b5de7608d8f0816087%7Ca8eec281aaa34daeac9b9a398b9215e7%7C0%7C0%7C637523785750125027%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=NNiAnkp7ayjQ5QNUyXKl5rugWBSCjrwwGOKU2vlB8O8%3D&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 at northeastern.edu > (617) 373-5983
…you’re right, now I got it. I’ve added an issue to track this down [1].
Thanks, Christian
Quoted text · Ash · 79 lines
On Fri, Mar 26, 2021 at 7:11 PM Clark, Ash <as.clark at northeastern.edu> wrote: > > 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 at gmail.com> > Sent: Friday, March 26, 2021 2:02 PM > To: Clark, Ash <as.clark at northeastern.edu> > Cc: basex-talk at mailman.uni-konstanz.de <basex-talk at 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&data=04%7C01%7Cas.clark%40northeastern.edu%7Cf1fb89b7dd5942b5de7608d8f0816087%7Ca8eec281aaa34daeac9b9a398b9215e7%7C0%7C0%7C637523785750125027%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=NNiAnkp7ayjQ5QNUyXKl5rugWBSCjrwwGOKU2vlB8O8%3D&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 at 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&data=04%7C01%7Cas.clark%40northeastern.edu%7Cf1fb89b7dd5942b5de7608d8f0816087%7Ca8eec281aaa34daeac9b9a398b9215e7%7C0%7C0%7C637523785750125027%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=NNiAnkp7ayjQ5QNUyXKl5rugWBSCjrwwGOKU2vlB8O8%3D&reserved=0"; > > declare namespace db="https://nam12.safelinks.protection.outlook.com/?url=http%3A%2F%2Fbasex.org%2Fmodules%2Fdb&data=04%7C01%7Cas.clark%40northeastern.edu%7Cf1fb89b7dd5942b5de7608d8f0816087%7Ca8eec281aaa34daeac9b9a398b9215e7%7C0%7C0%7C637523785750125027%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=DFp3e%2FG5fJRnDGPiVW6MJ1TivSgrUbi6u2%2F%2BmIq%2B%2B90%3D&reserved=0"; > > declare namespace output="https://nam12.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.w3.org%2F2010%2Fxslt-xquery-serialization&data=04%7C01%7Cas.clark%40northeastern.edu%7Cf1fb89b7dd5942b5de7608d8f0816087%7Ca8eec281aaa34daeac9b9a398b9215e7%7C0%7C0%7C637523785750125027%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=jQg422TqEiDRyIZW78hq5A9ZqBnBp0luX89Dh5AoGvI%3D&reserved=0"; > > declare namespace update="https://nam12.safelinks.protection.outlook.com/?url=http%3A%2F%2Fbasex.org%2Fmodules%2Fupdate&data=04%7C01%7Cas.clark%40northeastern.edu%7Cf1fb89b7dd5942b5de7608d8f0816087%7Ca8eec281aaa34daeac9b9a398b9215e7%7C0%7C0%7C637523785750125027%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=sSviqimFx6wpj%2FTTzvF%2BlF3O92jbHmDg3CUyP%2FA5Wj0%3D&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&data=04%7C01%7Cas.clark%40northeastern.edu%7Cf1fb89b7dd5942b5de7608d8f0816087%7Ca8eec281aaa34daeac9b9a398b9215e7%7C0%7C0%7C637523785750125027%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=kWqR84qP0C%2BSAM0Sr6KtyZQqs%2F%2F2dvcfeKMp1yYBu5g%3D&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&data=04%7C01%7Cas.clark%40northeastern.edu%7Cf1fb89b7dd5942b5de7608d8f0816087%7Ca8eec281aaa34daeac9b9a398b9215e7%7C0%7C0%7C637523785750125027%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=NNiAnkp7ayjQ5QNUyXKl5rugWBSCjrwwGOKU2vlB8O8%3D&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 at northeastern.edu > > (617) 373-5983
Okay. Thanks again!
~Ash
Quoted text · Christian Grün · 88 lines
From: Christian Grün <christian.gruen at gmail.com> Sent: Friday, March 26, 2021 2:24 PM To: Clark, Ash <as.clark at northeastern.edu> Cc: basex-talk at mailman.uni-konstanz.de <basex-talk at mailman.uni-konstanz.de> Subject: Re: [basex-talk] Missing namespaces when storing an excerpt? …you’re right, now I got it. I’ve added an issue to track this down [1]. Thanks, Christian [1] https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FBaseXdb%2Fbasex%2Fissues%2F1997&data=04%7C01%7Cas.clark%40northeastern.edu%7C892198771cea4356911208d8f0847b39%7Ca8eec281aaa34daeac9b9a398b9215e7%7C0%7C0%7C637523799080865663%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=47hW2k9YPSxODOsKng2sUnguB9you%2FV48BP2rWUCblQ%3D&reserved=0 On Fri, Mar 26, 2021 at 7:11 PM Clark, Ash <as.clark at northeastern.edu> wrote: > > 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 at gmail.com> > Sent: Friday, March 26, 2021 2:02 PM > To: Clark, Ash <as.clark at northeastern.edu> > Cc: basex-talk at mailman.uni-konstanz.de <basex-talk at 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&data=04%7C01%7Cas.clark%40northeastern.edu%7C892198771cea4356911208d8f0847b39%7Ca8eec281aaa34daeac9b9a398b9215e7%7C0%7C0%7C637523799080865663%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=GoTB4mKRMHwybDktAKMOGx1WtG5DBOKX1ykts1UKATk%3D&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 at 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&data=04%7C01%7Cas.clark%40northeastern.edu%7C892198771cea4356911208d8f0847b39%7Ca8eec281aaa34daeac9b9a398b9215e7%7C0%7C0%7C637523799080865663%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=GoTB4mKRMHwybDktAKMOGx1WtG5DBOKX1ykts1UKATk%3D&reserved=0"; > > declare namespace db="https://nam12.safelinks.protection.outlook.com/?url=http%3A%2F%2Fbasex.org%2Fmodules%2Fdb&data=04%7C01%7Cas.clark%40northeastern.edu%7C892198771cea4356911208d8f0847b39%7Ca8eec281aaa34daeac9b9a398b9215e7%7C0%7C0%7C637523799080865663%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=y050wBf%2FTypd2tr8E66U9Sg0Y4S%2F9mVL50fEtQK5m98%3D&reserved=0"; > > declare namespace output="https://nam12.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.w3.org%2F2010%2Fxslt-xquery-serialization&data=04%7C01%7Cas.clark%40northeastern.edu%7C892198771cea4356911208d8f0847b39%7Ca8eec281aaa34daeac9b9a398b9215e7%7C0%7C0%7C637523799080865663%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=9xMGv5AZGn5tVNBZBoG%2BaD4zFWndzWRlvItmkbDDz%2Fw%3D&reserved=0"; > > declare namespace update="https://nam12.safelinks.protection.outlook.com/?url=http%3A%2F%2Fbasex.org%2Fmodules%2Fupdate&data=04%7C01%7Cas.clark%40northeastern.edu%7C892198771cea4356911208d8f0847b39%7Ca8eec281aaa34daeac9b9a398b9215e7%7C0%7C0%7C637523799080865663%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=HTuU2EG13grOpjlayn%2BkAuIdkUg95rdAgyacDnyMvOE%3D&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&data=04%7C01%7Cas.clark%40northeastern.edu%7C892198771cea4356911208d8f0847b39%7Ca8eec281aaa34daeac9b9a398b9215e7%7C0%7C0%7C637523799080865663%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=WxiTtSUqaZmeQsR3tUJxZQNngy8hLs8Lzo7NjkXSo5Q%3D&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&data=04%7C01%7Cas.clark%40northeastern.edu%7C892198771cea4356911208d8f0847b39%7Ca8eec281aaa34daeac9b9a398b9215e7%7C0%7C0%7C637523799081064792%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=t1pnQs6BKN%2FSwrUQinfyket27lN5F36QK4c3Bfy5Tfo%3D&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 at northeastern.edu > > (617) 373-5983
The issue has been resolved; a new snapshot is available [1].
Cheers, Christian
Quoted text · Christian Grün · 91 lines
On Fri, Mar 26, 2021 at 7:24 PM Christian Grün <christian.gruen at gmail.com> wrote: > > …you’re right, now I got it. I’ve added an issue to track this down [1]. > > Thanks, > Christian > > [1] https://github.com/BaseXdb/basex/issues/1997 > > > > On Fri, Mar 26, 2021 at 7:11 PM Clark, Ash <as.clark at northeastern.edu> wrote: > > > > 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 at gmail.com> > > Sent: Friday, March 26, 2021 2:02 PM > > To: Clark, Ash <as.clark at northeastern.edu> > > Cc: basex-talk at mailman.uni-konstanz.de <basex-talk at 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&data=04%7C01%7Cas.clark%40northeastern.edu%7Cf1fb89b7dd5942b5de7608d8f0816087%7Ca8eec281aaa34daeac9b9a398b9215e7%7C0%7C0%7C637523785750125027%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=NNiAnkp7ayjQ5QNUyXKl5rugWBSCjrwwGOKU2vlB8O8%3D&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 at 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&data=04%7C01%7Cas.clark%40northeastern.edu%7Cf1fb89b7dd5942b5de7608d8f0816087%7Ca8eec281aaa34daeac9b9a398b9215e7%7C0%7C0%7C637523785750125027%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=NNiAnkp7ayjQ5QNUyXKl5rugWBSCjrwwGOKU2vlB8O8%3D&reserved=0"; > > > declare namespace db="https://nam12.safelinks.protection.outlook.com/?url=http%3A%2F%2Fbasex.org%2Fmodules%2Fdb&data=04%7C01%7Cas.clark%40northeastern.edu%7Cf1fb89b7dd5942b5de7608d8f0816087%7Ca8eec281aaa34daeac9b9a398b9215e7%7C0%7C0%7C637523785750125027%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=DFp3e%2FG5fJRnDGPiVW6MJ1TivSgrUbi6u2%2F%2BmIq%2B%2B90%3D&reserved=0"; > > > declare namespace output="https://nam12.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.w3.org%2F2010%2Fxslt-xquery-serialization&data=04%7C01%7Cas.clark%40northeastern.edu%7Cf1fb89b7dd5942b5de7608d8f0816087%7Ca8eec281aaa34daeac9b9a398b9215e7%7C0%7C0%7C637523785750125027%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=jQg422TqEiDRyIZW78hq5A9ZqBnBp0luX89Dh5AoGvI%3D&reserved=0"; > > > declare namespace update="https://nam12.safelinks.protection.outlook.com/?url=http%3A%2F%2Fbasex.org%2Fmodules%2Fupdate&data=04%7C01%7Cas.clark%40northeastern.edu%7Cf1fb89b7dd5942b5de7608d8f0816087%7Ca8eec281aaa34daeac9b9a398b9215e7%7C0%7C0%7C637523785750125027%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=sSviqimFx6wpj%2FTTzvF%2BlF3O92jbHmDg3CUyP%2FA5Wj0%3D&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&data=04%7C01%7Cas.clark%40northeastern.edu%7Cf1fb89b7dd5942b5de7608d8f0816087%7Ca8eec281aaa34daeac9b9a398b9215e7%7C0%7C0%7C637523785750125027%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=kWqR84qP0C%2BSAM0Sr6KtyZQqs%2F%2F2dvcfeKMp1yYBu5g%3D&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&data=04%7C01%7Cas.clark%40northeastern.edu%7Cf1fb89b7dd5942b5de7608d8f0816087%7Ca8eec281aaa34daeac9b9a398b9215e7%7C0%7C0%7C637523785750125027%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=NNiAnkp7ayjQ5QNUyXKl5rugWBSCjrwwGOKU2vlB8O8%3D&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 at northeastern.edu > > > (617) 373-5983
Works great! Thank you so much.
Warmly, Ash
Quoted text · Christian Grün · 100 lines
From: Christian Grün <christian.gruen at gmail.com> Sent: Saturday, March 27, 2021 11:21 AM To: Clark, Ash <as.clark at northeastern.edu> Cc: basex-talk at mailman.uni-konstanz.de <basex-talk at mailman.uni-konstanz.de> Subject: Re: [basex-talk] Missing namespaces when storing an excerpt? The issue has been resolved; a new snapshot is available [1]. Cheers, Christian [1] https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Ffiles.basex.org%2Freleases%2Flatest%2F&data=04%7C01%7Cas.clark%40northeastern.edu%7C7855ddec53b14a21ffc908d8f1340474%7Ca8eec281aaa34daeac9b9a398b9215e7%7C0%7C0%7C637524553003250437%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=elTY1qlLs0pMEgOaoAj2v4P4cIqSNqJLbCCurNSR9Q0%3D&reserved=0 On Fri, Mar 26, 2021 at 7:24 PM Christian Grün <christian.gruen at gmail.com> wrote: > > …you’re right, now I got it. I’ve added an issue to track this down [1]. > > Thanks, > Christian > > [1] https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FBaseXdb%2Fbasex%2Fissues%2F1997&data=04%7C01%7Cas.clark%40northeastern.edu%7C7855ddec53b14a21ffc908d8f1340474%7Ca8eec281aaa34daeac9b9a398b9215e7%7C0%7C0%7C637524553003250437%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=e8iel97fguBQfHW1j8MnSn3cMH0AqhDLg7gEok8%2B%2F%2FI%3D&reserved=0 > > > > On Fri, Mar 26, 2021 at 7:11 PM Clark, Ash <as.clark at northeastern.edu> wrote: > > > > 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 at gmail.com> > > Sent: Friday, March 26, 2021 2:02 PM > > To: Clark, Ash <as.clark at northeastern.edu> > > Cc: basex-talk at mailman.uni-konstanz.de <basex-talk at 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&data=04%7C01%7Cas.clark%40northeastern.edu%7C7855ddec53b14a21ffc908d8f1340474%7Ca8eec281aaa34daeac9b9a398b9215e7%7C0%7C0%7C637524553003250437%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=oU8KFhHXsAneX%2FsiX1tVbeR2Ugy3vRWgw9HUf5gYgZ0%3D&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 at 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&data=04%7C01%7Cas.clark%40northeastern.edu%7C7855ddec53b14a21ffc908d8f1340474%7Ca8eec281aaa34daeac9b9a398b9215e7%7C0%7C0%7C637524553003250437%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=oU8KFhHXsAneX%2FsiX1tVbeR2Ugy3vRWgw9HUf5gYgZ0%3D&reserved=0"; > > > declare namespace db="https://nam12.safelinks.protection.outlook.com/?url=http%3A%2F%2Fbasex.org%2Fmodules%2Fdb&data=04%7C01%7Cas.clark%40northeastern.edu%7C7855ddec53b14a21ffc908d8f1340474%7Ca8eec281aaa34daeac9b9a398b9215e7%7C0%7C0%7C637524553003250437%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=cQAIbgNu4k6iRKfzXbXokZTU2sbNbrBP5EAUY4DAd2o%3D&reserved=0"; > > > declare namespace output="https://nam12.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.w3.org%2F2010%2Fxslt-xquery-serialization&data=04%7C01%7Cas.clark%40northeastern.edu%7C7855ddec53b14a21ffc908d8f1340474%7Ca8eec281aaa34daeac9b9a398b9215e7%7C0%7C0%7C637524553003260404%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=DFQ0zGsi3FI8TwlDP0oZEhYsO5bffZPEk1EiDp6oo6Y%3D&reserved=0"; > > > declare namespace update="https://nam12.safelinks.protection.outlook.com/?url=http%3A%2F%2Fbasex.org%2Fmodules%2Fupdate&data=04%7C01%7Cas.clark%40northeastern.edu%7C7855ddec53b14a21ffc908d8f1340474%7Ca8eec281aaa34daeac9b9a398b9215e7%7C0%7C0%7C637524553003260404%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=1e1BeaRPhhe%2FyyFeAgblrsRz3O8zjjW8M1TDWA0UnjI%3D&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&data=04%7C01%7Cas.clark%40northeastern.edu%7C7855ddec53b14a21ffc908d8f1340474%7Ca8eec281aaa34daeac9b9a398b9215e7%7C0%7C0%7C637524553003260404%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=nL3vISKcGagPIRYo3VjpWcI8iiWf9FQ3e2Se24dqZ18%3D&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&data=04%7C01%7Cas.clark%40northeastern.edu%7C7855ddec53b14a21ffc908d8f1340474%7Ca8eec281aaa34daeac9b9a398b9215e7%7C0%7C0%7C637524553003260404%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=B%2FZpfWQdJFbdaY21vK3zBw66Okz0k%2Fl%2FXXym%2BLfmJ2Y%3D&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 at northeastern.edu > > > (617) 373-5983
Written for BaseX 9.5. BaseX may have changed since: please check the current documentation.