GithubHelp home page GithubHelp logo

Support MarkLogic behavior that falls back to XPath function namespace where no function in scope has given signature about intellij-xquery HOT 3 OPEN

willsthompson avatar willsthompson commented on August 21, 2024
Support MarkLogic behavior that falls back to XPath function namespace where no function in scope has given signature

from intellij-xquery.

Comments (3)

ligasgr avatar ligasgr commented on August 21, 2024

Hi,

Please have a look on the MarkLogic documentation here.

Library Modules Default Function Namespace Defaults to Library Namespace

The default function namespace of an XQuery library module is the namespace of the library module. This allows you to declare functions in the library namespace without prefixing the functions. You can override the default function namespace with a declare default function namespace declaration in the prolog of the library module. For library modules where you do not override the default function namespace (and as a general best-practice), you should prefix the XQuery-standard functions (functions with the fn: prefix, which is bound to the http://www.w3.org/2005/xpath-functions namespace) with the fn: prefix. Note that main modules default function namespace defaults to the fn: namespace, which is different from library modules.

When you select MarkLogic as the Flavour in the settings this is how the system will treat it for module libraries. For all other Flavours and for MarkLogic main modules the system behaves as you've described.
Please let me know if you've observed a different behaviour and provide examples!

from intellij-xquery.

willsthompson avatar willsthompson commented on August 21, 2024

That's interesting. The documentation is certainly clear, but that's not the behavior I see in ML v. 8.0-6.1 (and every previous version I've worked on). For example, a library module that makes several clearly meaningful XPath function calls:

xquery version "1.0-ml";
module namespace tn = "http://test/ML/default-namespace";

declare function tn:dostuff()
{
  string-join(
    for $i in tokenize('abc;123;jkl', ';')
    where true()
    return concat($i, '.')
  , ' ')
};

When imported into a main module, tn:dostuff() runs without error. Also interesting, even if you remove the tn prefix from tn:dostuff, it follows the behavior described in the documentation, associating it with the module namespace, while still resolving non-prefixed XPath functions to the XPath functions namespace.

But if an XPath function's local name is defined in the module namespace, any non-prefixed call to that function name will give priority to the module namespace over the XPath namespace:

declare function true()  (: Any call to true() instead of fn:true() will call this :)
{
  'foo' 
};

from intellij-xquery.

ligasgr avatar ligasgr commented on August 21, 2024

So the documentation is quite precise but leaves the last bit a bit 'undefined' where the implementation is actually quite strict.

It looks like if there is a local implementation in given module namespace then it goes to it. If there isn't it tries to fall-back to the default function namespace. Thanks for providing the examples and explanation!

from intellij-xquery.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.