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

[core] Expose collections from getters as XPath sequence attributes #4467

Closed
rsoesemann opened this issue Apr 12, 2023 · 3 comments · Fixed by #4969
Closed

[core] Expose collections from getters as XPath sequence attributes #4467

rsoesemann opened this issue Apr 12, 2023 · 3 comments · Fixed by #4969
Labels
an:enhancement An improvement on existing features / rules
Milestone

Comments

@rsoesemann
Copy link
Member

It tried writing a Custom Apex Rule using the Rule Designer that detected classes that implement or extend a certain Interface.

public class Example implements Queueable, Finalizer {

}

and failed because that information is not exposed in the AST (exposed in the Rule Designer)

Screenshot 2023-04-12 at 12 07 03

@rsoesemann rsoesemann added the an:enhancement An improvement on existing features / rules label Apr 12, 2023
@rsoesemann rsoesemann changed the title [apex] Expose implements, extends nodes to use it in Rule Designer / Custom rules [apex] Expose implements, extends for usage in Rule Designer / Custom rules Apr 12, 2023
@rsoesemann
Copy link
Member Author

@oowekyala and @adangel , do you know whether the root cause for this is:

  1. The Jorje AST not exposing it
  2. Our AST Wrapper not exposing it
  3. The Designer not exposing it

I guess depending on the answer the effort to fix it dramatically changes.

@adangel
Copy link
Member

adangel commented Oct 10, 2023

I had a look into this. On the Java side, we have access to the implemented interfaces:

But this getter is not exposed as a node attribute in XPath (in contrary to @SuperClassName, which is exposed as a simple attribute).

The reason is, that this is a List. At some time, we decided to not implement this (see #2451), because there was no use case. Now it seems, we have a use case? (Of course, you can write a Java-based rule instead of a XPath rule).

Implementing support for List/Collections seems to be in general a useful thing. I don't know however, how feasible this is, because of this quote: "attributes [in newer Saxon versions] are supposed to be always non-sequences.". This maybe has something to do with how Saxon tries to optimize the XPath expression - and if an attribute can be a sequence or a non-sequence optimization is probably harder.

So, someone needs to investigate, whether the claim, that attributes must be non-sequences is still valid. But it might very well be impossible to just return a list for an attribute: XPath operates on XML, and in XML attributes are simple values and not sequences. And the underlying model, we create for Saxon, so that it can execute the XPath expression, probably should mimic a valid XML model.

As described in the mentioned issue, one way could be to create custom xpath functions, whenever we want to have access to a list of things...

@adangel
Copy link
Member

adangel commented Apr 12, 2024

See also #4950

@adangel adangel added this to the 7.2.0 milestone Apr 25, 2024
@adangel adangel changed the title [apex] Expose implements, extends for usage in Rule Designer / Custom rules [core] Expose collections from getters as XPath sequence attributes May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
an:enhancement An improvement on existing features / rules
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants