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 in document-node(element(xxx)) #1932

Closed
djbpitt opened this issue Jun 9, 2018 · 7 comments · Fixed by #3287
Closed

bug in document-node(element(xxx)) #1932

djbpitt opened this issue Jun 9, 2018 · 7 comments · Fixed by #3287
Assignees
Labels
bug issue confirmed as bug
Milestone

Comments

@djbpitt
Copy link

djbpitt commented Jun 9, 2018

What is the problem

Describe exactly what you see (e.g. an output of an XQuery)

declare namespace tei="http://www.tei-c.org/ns/1.0";
declare variable $play as document-node(element(tei:TEI)) := doc('/db/apps/shakespeare/data/ham.xml');
$play

returns zero results in eXist-db 4.0, although the play exists. It returns one result, as expected, in <oXygen/>.

What did you expect

I expected it to return the play:

document-node( E ) matches any document node that contains exactly one element node, optionally accompanied by one or more comment and processing instruction nodes, if E is an ElementTest or SchemaElementTest that matches the element node (see 2.5.5.3 Element Test and 2.5.5.4 Schema Element Test).

Example: document-node(element(book)) matches a document node containing exactly one element node that is matched by the ElementTest element(book).

(https://www.w3.org/TR/xpath-31/#id-matching-item)

Describe how to reproduce or add a test

Run the example above on an eXist-db installation with the Shakespeare app installed.

Context information

  • eXist-db version + Git Revision hash: eXist-db 4.0 / cc66ebc
  • Java version: java version "1.8.0_45", Java(TM) SE Runtime Environment (build 1.8.0_45-b14), Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)
  • Operating system: MacOs 10.11.6 (15G20015)
  • 32 or 64 bit: 64 bit
  • How is eXist-db installed: JAR installer
  • Any custom changes: none
@triage-new-issues triage-new-issues bot added the triage issue needs to be investigated label Jun 9, 2018
@joewiz joewiz added the bug issue confirmed as bug label Jun 9, 2018
@triage-new-issues triage-new-issues bot removed the triage issue needs to be investigated label Jun 9, 2018
@joewiz joewiz added this to the eXist-4.2.1 milestone Jun 9, 2018
@duncdrum
Copy link
Contributor

duncdrum commented Jun 9, 2018

To fix this we need to fix #1463 first. Coming to think of it this seems a duplicate issue @joewiz ?
the bug is that the above is wrongly treated as:

document-node(document-node(tei:TEI))

@joewiz
Copy link
Member

joewiz commented Jun 9, 2018

Here is an xqsuite test demonstrating the failure:

xquery version "3.1";

module namespace mi = "http://exist-db.org/test/matching-item";

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

declare
    %test:assertTrue
function mi:document() { 
    document { element book {} } instance of document-node()
};

declare
    %test:assertTrue
function mi:document-element() { 
    document { element book {} } instance of document-node( element() )
};

declare
    %test:assertTrue
function mi:document-element-name() { 
    document { element book {} } instance of document-node( element(book) )
};

This currently returns the following results:

<testsuites>
    <testsuite package="http://exist-db.org/test/matching-item"
        timestamp="2018-06-09T14:43:20.033-04:00" failures="1" pending="0"
        tests="3" time="PT0.009S">
        <testcase name="document" class="mi:document"/>
        <testcase name="document-element" class="mi:document-element"/>
        <testcase name="document-element-name" class="mi:document-element-name">
            <failure message="assertTrue failed." type="failure-error-code-1"/>
            <output>false</output>
        </testcase>
    </testsuite>
</testsuites>

@adamretter
Copy link
Contributor

I think as this is in the query processor it is probably one for @wolfgangmm

@joewiz
Copy link
Member

joewiz commented Sep 10, 2019

This bug is still present in eXist 5.0.0.

@adamretter adamretter modified the milestones: eXist-5.0.1, eXist-5.1.1 Nov 19, 2019
@adamretter adamretter modified the milestones: eXist-5.1.1, eXist-5.1.2 Dec 6, 2019
@adamretter adamretter modified the milestones: eXist-5.1.2, eXist-5.2.1 Jan 23, 2020
@adamretter
Copy link
Contributor

@duncdrum actually #1463 is not related to this

@adamretter
Copy link
Contributor

@joewiz nice tests, but actually they are testing for something different to the issue that @djbpitt reported. I have incorporated both into a new PR.

@joewiz
Copy link
Member

joewiz commented Mar 10, 2020

@adamretter Approved by @dizzzz and now merged. Many thanks! And thanks to @djbpitt for reporting the issue! (See the tests that are now in the source code to prevent future regressions: https://github.com/eXist-db/exist/blob/develop/exist-core/src/test/xquery/document-nodes.xq.)

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

Successfully merging a pull request may close this issue.

5 participants