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?fil..." 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/eirhttp://pronoun.is/e/em/eir) XML Applications Developer Digital Scholarship Group Northeastern University Libraries as.clark@northeastern.edu (617) 373-5983