Add new GREL function to support Jsoup parent() function to complement our select() #4181
Labels
Good First Issue
Indicates issues suitable for newcomers to design or coding, providing a gentle introduction.
grel
The default expression language, GREL, could be improved in many ways!
Type: Feature Request
Identifies requests for new features or enhancements. These involve proposing new improvements.
Milestone
There is no easy way to navigate up the parse tree provided by jsoup selector syntax. We currently can navigate down very easily with Jsoup's selector syntax
value.parseHtml().select("div > p")
and alsovalue.parseHtml().select("div:has(@) ~ div")
butthis does not directly allow DOM traversal itself. However, Jsoup conveniently provides DOM traversal for finding a https://jsoup.org/apidocs/org/jsoup/nodes/Element.html#parent()
which mimics the behavior from BeautifulSoup's https://www.crummy.com/software/BeautifulSoup/bs4/doc/#parent
Proposed solution
Add a new GREL function for the jsoup method
parent()
and for simplicity sake just call the GREL functionparent()
Alternatives considered
A difficult path of custom installed Jython 2.7 with BeautifulSoup
Additional context
Existing code for
select()
functionality is here:https://github.com/OpenRefine/OpenRefine/blob/master/main/src/com/google/refine/expr/functions/xml/SelectXml.java
and function registration to be added to is here:
https://github.com/OpenRefine/OpenRefine/blob/master/main/src/com/google/refine/grel/ControlFunctionRegistry.java#L249
The text was updated successfully, but these errors were encountered: