Hi, 

My search function used to return $html correctly

let $html := <html xmlns="http://www.w3.org/1999/xhtml">
    <head><link href="{$cssfile}" rel="stylesheet" type="text/css"/><title>Search help</title>
    <script type="text/javascript" xmlns="http://www.w3.org/1999/xhtml">{app:get-google-analytics-script()/text()}</script>
    </head>
    <body>
      <div> (…)
     <div>{$result-list}</div>
   </div></body></html>
return $html


I am now trying to keep records of users most popular queries in my DB, so I made the function an updating function and adapted the return value:

let $html := <html xmlns="http://www.w3.org/1999/xhtml">
    <head><link href="{$cssfile}" rel="stylesheet" type="text/css"/><title>Search help</title>
    <script type="text/javascript" xmlns="http://www.w3.org/1999/xhtml">{app:get-google-analytics-script()/text()}</script>
    </head>
    <body>
      <div> (…)
     <div>{$result-list}</div>
   </div></body></html>

   return (feedback:analyze-user-search-and-result($keywords, $result-ids, $this-menu, $application, $carrier, $country, $lang, $model, $os), db:output($html))


I got this error: error on line 30 at column 25: Attribute xmlns redefined

After lots of research, I figured that when using db:output, the top element of $result-list is interpreted as coming from a different namespace. Adding xmlns="http://www.w3.org/1999/xhtml" to that top element resolved my issue, but I still don't get why this is happening, can you explain?

More specifically, here are definitions of $result-lists and what they produce:

let $result-list := <div/> would work when used in the 1st code sample, but not the second (updating function).
let $result-list := <div xmlns:="http://www.w3.org/1999/xhtml"/>  resolves the issue for the second (updating function).

Thanks,

France

--
France Baril
Architecte documentaire / Documentation architect
france.baril@architextus.com
(514) 572-0341