Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] doc-available must work in a predicate #5220

Open
line-o opened this issue Feb 7, 2024 · 0 comments
Open

[BUG] doc-available must work in a predicate #5220

line-o opened this issue Feb 7, 2024 · 0 comments
Labels
bug issue confirmed as bug
Milestone

Comments

@line-o
Copy link
Member

line-o commented Feb 7, 2024

Describe the bug

doc-available cannot be used in a predicate.

('/db/a', '/db/b')[doc-available(.)]

yields

exerr:ERROR XPTY0004: The actual cardinality for parameter 1 does not match the cardinality declared in the function's signature: doc-available($document-uri as xs:string?) xs:boolean. Expected cardinality: zero or one, got 2. [at line 1, column 20, source: String/-2946985203662395848]

Expected behavior

In the above case the expected return value is an empty sequence as both path very likely point to a non XML document.

To Reproduce

xquery version "3.1";

module namespace t="http://exist-db.org/xquery/test";

declare namespace test="http://exist-db.org/xquery/xqsuite";

declare
    %test:setUp
function t:setup() {
    xmldb:create-collection("/db", "test"),
    xmldb:store("/db/test", "doc.xml", <root />),
    xmldb:store("/db/test", "bin",  "...")
};

declare
    %test:tearDown
function t:tearDown() {
    xmldb:remove("/db/test")
};

declare
    %test:assertEquals("/db/test/doc.xml")
function t:doc-available-in-predicate() {
    uri-collection("/db/test")[doc-available(.)]
};

declare
    %test:assertEquals("/db/test/bin")
function t:util-binary-doc-available-in-predicate() {
    uri-collection("/db/test")[util:binary-doc-available(.)]
};

On exist-6.2.0 only the second test passes.

Context (please always complete the following information)

Build: eXist-6.3.0-SNAPSHOT (b55849d)
Java: 1.8.0_362 (Azul Systems, Inc.)
OS: Mac OS X 14.3 (aarch64)

Additional context

  • How is eXist-db installed? built from source
  • Any custom changes in e.g. conf.xml? none
@joewiz joewiz added this to the eXist-6.2.1 milestone Feb 8, 2024
@joewiz joewiz added the bug issue confirmed as bug label Feb 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug issue confirmed as bug
Projects
None yet
Development

No branches or pull requests

2 participants