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

Implement fn:path#0 and fn:path#1 #4402

Merged
merged 14 commits into from
Jun 17, 2022

Conversation

chris-evolvedbinary
Copy link
Contributor

@chris-evolvedbinary chris-evolvedbinary commented May 23, 2022

Implementation of the fn:path() function. This implementation requires fixing an issue with document nodes.

Reference:

Type of tests:

  • exist-core/src/test/xquery/xquery3/fnPath.xqm

--

This open source contribution to the eXist-db project was commissioned by the Office of the Historian, U.S. Department of State, https://history.state.gov/.

@adamretter adamretter changed the title Feature/fn path#0,#1 Implement fn:path#0 and fn:path#1 May 23, 2022
@adamretter adamretter added this to the eXist-6.1.0 milestone May 23, 2022
@adamretter adamretter added the enhancement new features, suggestions, etc. label May 23, 2022
@adamretter adamretter requested a review from a team May 23, 2022 17:23

final StringBuilder value = new StringBuilder();
final StringBuilder attributeValue = new StringBuilder();
if (node.getNodeType() == Type.TEXT) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a switch would be more correct here?

// its comment node siblings.
final int nodePosition = getNodePosition(node);
if (nodePosition > 0) {
value.append(String.format("/comment()[%d]", nodePosition));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the 1st position nodePosition 0 or 1 ?
does the XQTS not require /comment() (without indication) to be used iso /comment()[1] ?

Copy link
Contributor

@adamretter adamretter Jun 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dizzzz This is passing all XQTS tests for fn-path

// like-named processing-instruction node siblings.
final int nodePosition = getNodePosition(node);
if (nodePosition > 0) {
value.append(String.format("/processing-instruction(%s)[%d]", node.getNodeName(), nodePosition));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same position question

Copy link
Contributor

@adamretter adamretter Jun 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dizzzz This is passing all XQTS tests for fn-path

@dizzzz
Copy link
Member

dizzzz commented May 23, 2022

how to deal with #1463 ? It caused me to hold my PR....

Copy link
Member

@dizzzz dizzzz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, some smaller questions

@joewiz joewiz added the xquery issue is related to xquery implementation label May 25, 2022
@adamretter adamretter marked this pull request as draft May 29, 2022 09:53
@chris-evolvedbinary chris-evolvedbinary marked this pull request as ready for review June 6, 2022 16:36
@adamretter
Copy link
Contributor

@chris-evolvedbinary Also could you please use the prefixes in your commit messages. If you look at the commit log you will see we use prefixes like [bugfix], [feature], [test], [refactor], etc.

@adamretter
Copy link
Contributor

How to deal with #1463 ? It caused me to hold my PR....

@dizzzz this will replace that PR and add some additional fixes for fn:root also.

@sonarcloud
Copy link

sonarcloud bot commented Jun 15, 2022

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 15 Code Smells

77.4% 77.4% Coverage
6.5% 6.5% Duplication

@adamretter adamretter self-requested a review June 15, 2022 14:10
Copy link
Contributor

@adamretter adamretter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now it looks good to me :-)

@dizzzz dizzzz merged commit ba90070 into eXist-db:develop Jun 17, 2022
@chris-evolvedbinary chris-evolvedbinary deleted the feature/fn-path#0,#1 branch June 28, 2022 20:49
joewiz added a commit to HistoryAtState/hsg-shell that referenced this pull request Apr 25, 2024
Before eXist 6.1.0, eXist’s implementation of the fn:root() function contained a bug that caused it to always return a document node, even when called on an in-memory node whose root node was an element node. This bug was fixed in eXist-db/exist#4402.

The only code in hsg-shell that assumed the buggy behavior was the code that handled the display of concurrent appointments in POCOM data.

After upgrading HSG from 5.1.1 to 6.2.0, this code triggered an error.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement new features, suggestions, etc. xquery issue is related to xquery implementation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Element constructor creates document node. It should not.
5 participants