Setup:
TEST #1

Test: Call http://localhost:8984/restxq/testsearch?keywords=phone
         * Replace phone by a keyword available in your 'en-us' DB.

You should get the following error:

Inline image 1
TEST #2

If you make the function non-updating and replace line 36

   return (searchhlp:analyze-user-search-and-result(), db:output($html))

by line 35

    return $html


You'll see that the same $html is a working HTML page.

TEST #3. 

Back to the updating function

Comment our line 35
return $html

Get line 36 back
  return (searchhlp:analyze-user-search-and-result(), db:output($html))

You are back to the code from TEST #1, and should get the same error.

Now, on line #13, change let $result := <div>
with let $result := <div xmlns="http://www.w3.org/1999/xhtml">

It works.

CONCLUSION
Sending the HTML through db:output changes something in the way @xmlns is processed.


On Fri, Nov 2, 2012 at 1:03 PM, Christian Grün <christian.gruen@gmail.com> wrote:
Hi France,

I tried a while to reproduce the issue you've been presenting, but I
didn't succeed so far. Do you think you could create a runnable
example for testing, or are there too many other components involved?

Thanks in advance,
Christian

___________________________

Christian Grün
Box 188, Uni KN
D-78457 Konstanz
http://christian-gruen.de


On Thu, Nov 1, 2012 at 4:01 PM, France Baril
<france.baril@architextus.com> wrote:
> 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
>
> _______________________________________________
> BaseX-Talk mailing list
> BaseX-Talk@mailman.uni-konstanz.de
> https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
>



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