Skip to content

129: Context item generalized to context value#368

Closed
michaelhkay wants to merge 5 commits into
qt4cg:masterfrom
michaelhkay:Issue129-context-value
Closed

129: Context item generalized to context value#368
michaelhkay wants to merge 5 commits into
qt4cg:masterfrom
michaelhkay:Issue129-context-value

Conversation

@michaelhkay

@michaelhkay michaelhkay commented Feb 21, 2023

Copy link
Copy Markdown
Contributor

This is a first cut proposal to generalize the context item to a context value, allowing (for example) array predicates.

The proposal covers XPath and XQuery only at this stage; it doesn't address the consequences for XSLT.

Careful review requested!

Addresses issue #129 and issue #367.

@ChristianGruen

Copy link
Copy Markdown
Contributor

Very appreciated!

I didn’t find anything dubious, and it’s pleasant to see that the context item and position can also be utilized for context values (when using the new array predicate). It’s mostly the path expressions that I believe need more discussion:

  1. After more consideration, I think we should discard the simple map operator, go further and treat / as ~/(fn:root(.) treat as document-node()). Path expressions are known to return ordered and duplicate-free results. A context value may contain all kinds of nodes (not only document nodes). As an example, it would be surprising if a path expression on an input sequence of nodes (that all belong to the same document) would return multiple results:
document { <xml><a/><a/></xml> }//a => { /xml }
  1. If possible anyhow, we should also adjust relative paths to take advantage of the context value: a and ~/a should be equivalent (by analogy with a and ./a, which are equivalent for single context nodes). It would be great – and certainly consistent and orthogonal – if we managed to get all the following expressions working:
Items Sequences
declare context value := doc('x.xml'); //item/name declare context value := doc('x.xml')//item; name
$nodes -> { a/b/c } $nodes => { a/b/c }
$nodes[a/b/c] $array?[a/b/c]

role="parse-test"
>E2</code>. Evaluation of E1 continues with its original focus unchanged.</p>

<p diff="add" at="2023-02-20">The examples above all process a sequence of items

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Unclear what examples are meant in the preceding paragraph. The term "all" is ambiguous (object of "above" or modifier of "examples"). Better?: "In each of the preceding situations, a sequence...is processed one item at a time." Consider changing other cases of "example" in this paragraph to "situation"

@ChristianGruen ChristianGruen changed the title Issue 129 - Context item generalized to context value 129: Context item generalized to context value May 2, 2023
@ndw ndw added the Revise PR has been discussed and substantive changes requested label Jun 6, 2023
@ChristianGruen

Copy link
Copy Markdown
Contributor

For those who have time to check out this topic:

I have reworked the initial comment of #129 by adding explanatory comments and aligning it with the features from the latest version of the specs.

@michaelhkay

Copy link
Copy Markdown
Contributor Author

Replaced by a new PR

@michaelhkay michaelhkay deleted the Issue129-context-value branch February 6, 2025 10:21
@michaelhkay michaelhkay added Abandoned PR was rejected, withdrawn, or superseded and removed Revise PR has been discussed and substantive changes requested labels Feb 6, 2025
@michaelhkay

Copy link
Copy Markdown
Contributor Author

Overtaken by PR #970

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Abandoned PR was rejected, withdrawn, or superseded

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants