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

701: fn:concat: Support for 0 or more arguments #702

Merged
merged 2 commits into from
Sep 19, 2023
Merged

Conversation

ChristianGruen
Copy link
Contributor

Closes #701

Copy link
Contributor

@michaelhkay michaelhkay left a comment

Choose a reason for hiding this comment

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

For a bit more precision, I'd suggest defining it as:

This function accepts zero or more arguments, each declared with the required type xs:anyAtomicType*. The value supplied for each argument is reduced to a single string by applying the fn:string-join#1 function; the resulting sequence of strings (one for each supplied argument) is then reduced to a single string by a further application of fn:string-join#1.

@michaelhkay
Copy link
Contributor

michaelhkay commented Sep 16, 2023

Hmmm... I think that accepting sequences breaks 1.0 compatibility mode. In XPath 1.0, concat(//h1, //h2) concatenates the value of the first h1 element and the first h2 element. XPath 4.0 in 1.0 compatible mode would no longer reproduce that behaviour. Perhaps we should drop that part of the proposal.

We could make the actual semantics of the function dependent on whether compatibility mode is set in the static context. I don't think we have a precedent for that, but I can't see any harm in it.

@ChristianGruen
Copy link
Contributor Author

ChristianGruen commented Sep 16, 2023

the resulting sequence of strings (one for each supplied argument) is then reduced to a single string by a further application of fn:string-join#1.

I wonder if it would make a difference to invoke string-join just once for all strings, or repeatedly for the strings of each argument?

We could make the actual semantics of the function dependent on whether compatibility mode is set in the static context.

Would be fine by me. I might be overwhelmed finding the right wording, though. Would you be ready to revise the PR?

@michaelhkay
Copy link
Contributor

I wonder if it would make a difference to invoke string-join just once for all strings

It wouldn't make a difference, it would just be a little bit more difficult to define (I think).

@michaelhkay
Copy link
Contributor

michaelhkay commented Sep 16, 2023

For 1.0 compatibility, try:

This function accepts zero or more arguments, each declared with the required type xs:anyAtomicType*. The value $A supplied for each argument is first reduced to a single string as follows:

  • if XPath 1.0 compatibility mode is set to true in the static context of the function call, then the result of xs:string($A[1])

  • Otherwise, the result of fn:stirng-join($A)

The resulting sequence of strings (one for each supplied argument) is then reduced to a single string by applying the function fn:string-join#1 to the sequence.

@ChristianGruen
Copy link
Contributor Author

Revised as suggested, thanks.

@ndw
Copy link
Contributor

ndw commented Sep 19, 2023

The CG agreed to accept this PR at meeting 046.

@ndw ndw merged commit d035dd2 into qt4cg:master Sep 19, 2023
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

fn:concat: Support for 0 or more arguments
3 participants