jbrehr
jbrehr

Reputation: 815

xquery (eXist-db) - imported module not found

I have a file "globalvar.xql" which contains what I hope can be a central document for all my non-varying variables (parameters really).

In order to use these, I understand that I have to declare/import the module into any other document that will use them. In this case, I want to use them in the functions found in "person.xql". As such, I have tried a declaration:

import module namespace globalvar="/db/apps/deheresi/modules/globalvar.xqm";

But I get the error message when I validate:

Cannot compile xquery: exerr:ERROR error found while loading module globalvar: Error while loading module /db/apps/deheresi/modules/globalvar.xqm: namespace URI declared by module (/db/apps/deheresi/modules/globalvar) does not match namespace URI in import statement, which was: /db/apps/deheresi/modules/globalvar.xqm

Error, code and directory are picture below.

I've been trying to imitate the code found in the eXist-db demos, and looking at other resources, but the error is mystifying me.

Many thanks.

Screen shot of code and error

Upvotes: 1

Views: 444

Answers (1)

Joe Wicentowski
Joe Wicentowski

Reputation: 5294

In your module import declaration, you've conflated the target module's namespace URI and location URI.

To fix it, you'll need to (1) add the namespace URI where you currently have the location URI, (2) add an at clause, and (3) move the location URI to its correct location following the at clause.

In other words, it should look like this:

import module namespace globalvar="globalvar-namespace-uri" at "/db/apps/deheresi/modules/globalvar.xqm";

Of course, "globalvar-namespace-uri" here is just a placeholder for the target module's namespace URI. It will need to match the namespace URI defined in the target module.

Upvotes: 3

Related Questions