Reputation: 2000
I have a file that exist at the same level as rewrite.xqy
i.e. it doesn't exist inside a particular directory. When i am declaring a module namespace
for it, I get the following error-
<error:message>Cannot evaluate library module</error:message>
<error:format-string>XDMP-EVALLIBMOD: Cannot evaluate library module:
What is the logic behind this as when I remove module namespace
it works just fine. These are the starting lines of my file-
xquery version "1.0-ml";
module namespace adv = "http://***/***/adv";
import module namespace search = "http://marklogic.com/appservices/search"
at "/Marklogic/appservices/search/search.xqy";
'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">',
xdmp:set-response-content-type("text/html; charset=utf-8"),
<html xmlns="http://www.w3.org/1999/xhtml">
Upvotes: 1
Views: 417
Reputation: 66783
When you define a module namespace, your module is expected to be a library module with a collection of functions. You don't "run" a library module though. If you attempt to run this code, for example by pasting into QConsole, you will get the XDMP-EVALLIBMOD error.
A main module is expected to be executed as an XQuery program. Remove the module namespace module namespace adv = "http://***/***/adv";
, and it will execute without error.
Or you can insert the code as a library module with the logic enclosed as the body of a function, import that module in a main module and call the function.
Upvotes: 3
Reputation: 3732
The error
<error:message>Cannot evaluate library module</error:message>
<error:format-string>XDMP-EVALLIBMOD: Cannot evaluate library module:
Means you are attempting to directly evaluate your code/module not import it. How are you getting this error ? For a xquery module, you cannot invoke it directly, you must import it in another file (usually the one you are invoking).
XQuery does not allow a single file to be both a main entry point and a module. When you say it 'works just fine' -- thats a good place to stop.
Upvotes: 1