Exist: [BUG] util:registered-functions returns QNames with null namespace prefixes

Created on 21 May 2020  路  4Comments  路  Source: eXist-db/exist

Describe the bug

For a small number of eXist extension functions, util:registered-functions returns results with a null namespace prefix.

This causes incorrect the namespace prefix for affected functions to be omitted in eXist's function documentation, and prevents IDEs such as oXygen from accessing the affected functions when users request function autocompletion/documentation based on a function's prefix. (See screenshots below.)

Affected functions:

  • http://exist-db.org/xquery/xmldb

    • copy-collection

    • copy-resource

  • http://exist-db.org/xquery/inspection

    • inspect-function

    • inspect-module

    • inspect-module-uri

  • http://exist-db.org/xquery/system

    • restore

  • http://exist-db.org/xquery/sql

    • execute

  • http://exist-db.org/xquery/util

    • absolute-resource-id

    • binary-doc

    • binary-doc-available

    • binary-doc-content-digest

    • document-id

    • document-name

    • eval

    • eval-and-serialize

    • eval-inline

    • eval-with-context

    • get-resource-by-absolute-id

    • is-binary-doc

    • qname-index-lookup

  • http://exist-db.org/xquery/compression

    • deflate

    • gzip

    • inflate

    • tar

    • ungzip

    • zip

Expected behavior

Every function returned by util:registered-functions should have the namespace prefix of its parent module鈥攁nd should never return a null namespace prefix.

To Reproduce

The query below lists which functions are affected.

xquery version "3.1";

for $namespace-uri in util:registered-modules()
let $functions := try { util:registered-functions($namespace-uri) } catch * { <error>{$err:code} raised when getting registered functions for module {$namespace-uri}</error> }
return
    if ($functions instance of element(error)) then
        ()
    else
        let $prefix-analysis := 
            for $function in $functions
            group by $prefix := fn:prefix-from-QName($function)
            return
                map { 
                    "prefix": $prefix,
                    "functions": 
                        array { $function ! fn:local-name-from-QName(.) }
                }
        where count($prefix-analysis) gt 1
        order by $namespace-uri
        return
            map { 
                "module": $namespace-uri,
                "prefix-analysis": array { $prefix-analysis }
            }

Note, too, that running inspect:inspect-functions on the same modules returns results with a similar discrepancy - base64-encode has a prefix, whereas binary-doc lacks one:

<function name="util:base64-encode" module="http://exist-db.org/xquery/util"/>
<function name="binary-doc" module="http://exist-db.org/xquery/util"/>

Screenshots

oXygen's function documentation omits util:binary-doc:

Screenshot 2020-05-14 at 08 57 22

eXist's function documentation omits the prefix for util:binary-doc:

Screen Shot 2020-05-14 at 11 30 30 AM

Context (please always complete the following information):

  • OS: macOS 10.13.6
  • eXist-db version: 5.2.0, 5.3.0-SNAPSHOT
  • Java Version: 1.8.0_242 (Zulu 8.44.0.11-CA-macosx) (build 1.8.0_242-b20)

Additional context

  • How is eXist-db installed? DMG, source
  • Any custom changes in e.g. conf.xml? no
bug

All 4 comments

It looks like that all the 'wrong' functions use the same 'new' function definitions:

image

I found the issue... fix on its way

this sequence shall be empty:

for $namespace-uri in util:registered-modules()
let $functions := try { util:registered-functions($namespace-uri) } catch * { <error>{$err:code} raised when getting registered functions for module {$namespace-uri}</error> }
for $fie in $functions
return
    if( contains($fie,":") or contains($namespace-uri, "w3.org") )
    then   () else $fie || " in " || $namespace-uri 

@dizzzz Your test query is exactly right. Thank you!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mathias-goebel picture mathias-goebel  路  4Comments

adamretter picture adamretter  路  4Comments

mathias-goebel picture mathias-goebel  路  6Comments

adamretter picture adamretter  路  6Comments

joewiz picture joewiz  路  3Comments