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

Support newer XPath versions (3.0, 3.1) #29

Open
cdanger opened this issue Jun 20, 2024 · 7 comments
Open

Support newer XPath versions (3.0, 3.1) #29

cdanger opened this issue Jun 20, 2024 · 7 comments
Assignees
Labels
enhancement New feature or request

Comments

@cdanger
Copy link

cdanger commented Jun 20, 2024

XACML 3.0 only supports XPath 1.0 and 2.0 (which is over 10 years old). This is a enhancement proposal to support XPath 3.0 and/or latest 3.1.

The new features in XPath 3.0 / 3.1 are well summarized in Saxonica's documentation. Just to give a few:

  • String concatenation operator (||)
  • Simple mapping operator (!)
  • let expressions for declaring local variables
  • New functions head, tail, for-each, filter, for-each-pair, pi, sin, cos, tan, asin, acos, atan, sqrt, format-integer, and others
  • XPath maps and arrays.

EDIT:
One of the great features of XPath 3.1 is JSON processing and support of JSONPath-like evaluation. See this example based on Altova's documentation using the new parse-json function and lookup operator:

let $x := parse-json(.) return $x?employees?employee?age

This XPath expression applied to the string (JSON object) '{"employees" : {"employee" : {"id": 1, "name": "Chris", "age": 41}}}' for example will return 41.

In this example the 'parse-json' function returns a map which contains nested maps. The 'lookup' operator is used numerous times to access the associated values of keys in the nested maps i.e. ?employees?employee?age

@cdanger cdanger added the enhancement New feature or request label Jun 20, 2024
@cdanger cdanger self-assigned this Jun 20, 2024
@cdanger cdanger added this to the xacml-core-3.1 milestone Jun 20, 2024
@steven-legg
Copy link

It makes sense to support the latest available version. Support for XPath is optional so including 3.0/3.1 doesn't impose a burden on implementators who ignore XPath.

There is a section in the core spec that discusses the implementation-defined aspects of XPath 2.0. We should also cover XPath 3.0/3.1.

@cdanger
Copy link
Author

cdanger commented Jul 9, 2024

I added a paragraph to my original comment on JSON processing capabilities introduced in XPath 3.1, which allows to mimic JSONPath (#5 ) evaluation with XPath syntax!

@cdanger
Copy link
Author

cdanger commented Jul 9, 2024

Should we also deprecate XPath 1.0?

@humantypo
Copy link

25 years seems like a good run so that makes sense to me. Given that XPath 3.1 has been around for 7 years is it reasonable to ask the same thing about XPath 2.0 in v4?

@cdanger
Copy link
Author

cdanger commented Jul 23, 2024

Well, XPath 2.0 was last updated in 2016 and still widely used as far as I know, so I would not throw it away just yet. Also last time I checked there are not so many XPath 3.x implementations out there. Sure we have at least one in Java, so no problem there, but other developers in other programming languages might not be so lucky. What's your experience?

@humantypo
Copy link

My experience is that everything in my world has moved to JSON :)

I did some poking around and it looks like XPath 2 is still very much in use...to the point that it seems pretty clear there isn't a lot of interest in XPath these days.

@cdanger
Copy link
Author

cdanger commented Jul 26, 2024

Indeed, it's time to move that to a separate xacml profile #33 so that the JSON fan base doesn't have to deal with that in the core spec 😜 .
see #33

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants