[xquery-talk] Doing 'base-uri "{$base-uri}";' fails

Andreas Mixich mixich.andreas at gmail.com
Tue May 1 09:55:14 PDT 2018


Since the application I am writing can be installed on other hosts, the
`base-uri` must be configurable to that foreign host. I want to solve
this with a library module, that keeps domain specific configuration
separate to the user and which gets imported where needed.

Test case:

  declare namespace cfg = "ns:cfg";
  declare base-uri "{$cfg:base-uri}";
  declare variable $cfg:base-uri := "file:/S:/projects/xqfr/src/fragments/";

  let $file := doc("xhtml5-page.xhtml")
  return $file

Doing this test case, both Saxon and BaseX try to find the file in the
directory of their executable installation

  [FODC0002] Resource 'C:/Program Files (x86)/BaseX/xhtml5-page.xhtml'
  does not exist.

When using it in a module context, with Saxon I get:

  Invalid URI config.xqm: Invalid base URI: Illegal character in scheme
  name at index 0: {$cfg:base-uri}: {$cfg:base-uri}

Googling it, it appears to be Java itself, throwing the error message.
Thus the {$base-uri} may get passed verbatim, but when used outside of
the module context, it somehow gets caught, but without a signal.

Long story short: Is there a way to achieve what I want? Is there a
reason against hoisting variables in XQuery, that get 'declared'?

Would it make sense to file an enhancement request on 'www.w3.org/Bugs' ?

Goody Bye, Minden jót, Mit freundlichen Grüßen,
Andreas Mixich

More information about the talk mailing list