Repository navigation
XPathFilter: skip blank values and try the next expression - #2258
Merged
Merged
Conversation
Both XPathFilter implementations (JSoup and DOM) kept the first expression that matched for a key, even when its value was empty or whitespace-only. An empty <title> therefore stopped the META fallback for parse.title and stored an empty title. Blank values are now dropped; when an expression only gives blank values, the next expression for that key is tried, and nothing is stored if they are all blank. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
rzo1
approved these changes
Oct 23, 2026
Contributor
|
lgtm, thx. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to the review comment #2256 (comment), kept separate from #2256.
Problem
Both XPathFilter implementations in
corekeep the first expression that matches for a key:org.apache.stormcrawler.jsoup.XPathFilter, used by the JSoupFiltersorg.apache.stormcrawler.parse.filter.XPathFilter, used by the ParseFiltersThey keep it even when its value is empty or whitespace-only. With the usual configuration for
parse.title(//TITLEfirst, then a META fallback), a page with an empty<title>gets an emptyparse.title, and the fallback never runs. This already happens with HTML pages. It will be more common once #2256 runs the JSoupFilters on documents parsed by Tika, because Tika always writes a<title>element, even for an untitled PDF.Change
Behaviour change
Blank values are no longer stored at all, even next to non-blank ones. For example,
//SCRIPT[@type='text/javascript']on the test page used to return two values: an empty one for the external<script src=...>and the inline script. It now returns only the inline script.testScriptExtractionin both test classes is updated to match.Tests
New tests in
JSoupFiltersTestandXPathFilterTest:<title>and a<meta name="title">fallback stores the fallback.mvn -pl core test -Dtest='XPathFilterTest,JSoupFiltersTest': 18 tests, all pass. Without the change to the filters, the new tests fail.🤖 Generated with Claude Code