From 933744212afefed067af2f95e84ad6c2774da19e Mon Sep 17 00:00:00 2001 From: Ioannis Rousochatzakis Date: Sat, 26 Jul 2025 00:42:41 +0200 Subject: [PATCH 1/3] fix: Update XPathProcessor to correctly handle context predicates --- .../eu/europa/ted/eforms/xpath/XPathProcessor.java | 11 +++++++---- .../europa/ted/eforms/xpath/XPathProcessorTest.java | 4 ++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/main/java/eu/europa/ted/eforms/xpath/XPathProcessor.java b/src/main/java/eu/europa/ted/eforms/xpath/XPathProcessor.java index e6e92be..fa6ef4b 100644 --- a/src/main/java/eu/europa/ted/eforms/xpath/XPathProcessor.java +++ b/src/main/java/eu/europa/ted/eforms/xpath/XPathProcessor.java @@ -76,17 +76,20 @@ private static String getContextualizedXpath(Queue contextQueue, // we want to use a dot step with the predicate of the path. if (!contextQueue.isEmpty() && !pathQueue.isEmpty() && pathQueue.peek().isSameAsOrNarrowerThan(contextQueue.peek())) { - contextQueue.poll(); // consume the same step from the contextQueue + // Consume the same step from the contextQueue and get its predicates + List contextPredicates = contextQueue.poll().getPredicates(); + // Keep only the predicates that are not in the context. + String pathPredicates = pathQueue.poll().getPredicates().stream().filter(p -> !contextPredicates.contains(p)).collect(Collectors.joining("")); if (contextQueue.isEmpty()) { // Since there are no more steps in the contextQueue, the relative xpath should // start with a dot step to provide a context for the predicate. - relativeXpath += "." + pathQueue.poll().getPredicateText(); + relativeXpath += "." + pathPredicates; } else { // Since there are more steps in the contextQueue which we will need to navigate back to, - // using back-steps, we will use a back-step to provide context of the predicate. + // using back-steps, we will use a back-step to provide context for the predicate. // This avoids an output that looks like ../.[predicate] which is valid but silly. contextQueue.poll(); // consume the step from the contextQueue - relativeXpath += ".." + pathQueue.poll().getPredicateText(); + relativeXpath += ".." + pathPredicates; } } diff --git a/src/test/java/eu/europa/ted/eforms/xpath/XPathProcessorTest.java b/src/test/java/eu/europa/ted/eforms/xpath/XPathProcessorTest.java index 0ea12c1..dd62236 100644 --- a/src/test/java/eu/europa/ted/eforms/xpath/XPathProcessorTest.java +++ b/src/test/java/eu/europa/ted/eforms/xpath/XPathProcessorTest.java @@ -65,7 +65,7 @@ void testIdentical() { @Test void testIdentical_WithPredicates() { - assertEquals(".[d = e][f = g]", contextualize("/a/b/c[d = e]", "/a/b/c[d = e][f = g]")); + assertEquals(".[f = g]", contextualize("/a/b/c[d = e]", "/a/b/c[d = e][f = g]")); } @Test @@ -181,7 +181,7 @@ void testPredicateDifferent() { @Test void testPredicateMoreInXpath() { - assertEquals("..[e][f]/c/d", contextualize("/a/b[e]/c", "/a/b[e][f]/c/d")); + assertEquals("..[f]/c/d", contextualize("/a/b[e]/c", "/a/b[e][f]/c/d")); } @Test From ebe008b814e2941d8b2c6bb70c6514b3e2d9be7d Mon Sep 17 00:00:00 2001 From: Ioannis Rousochatzakis Date: Sat, 26 Jul 2025 00:46:42 +0200 Subject: [PATCH 2/3] Update release notes for eForms Core Library 1.5.0 --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b71fd51..c27169f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,10 @@ -# eForms Core Library 1.4.0 Release Notes +# eForms Core Library 1.5.0 Release Notes The eForms Core Library is a collection of utilities that are used by our sample applications as well as the EFX Toolkit for Java Developers. ## In this release -This release adds the option to indicate a qualifier for SDK components. If there are 2 or more classes that have an @SdkComponent annotation with the same version and component type, this allows you to differentiate them and load the component with the matching qualifier. +This release fixes an issue in the XPathProcessor that could cause a redundant predicate production when contextualising XPaths with multiple predicates. The versions of various dependencies was updated: ANTLR 4.13.1, JAXB 4.0.4, logback 1.5.3, ph-genericode 7.1.1. From dc8f377485a542f835152454922ad56a1f1980cf Mon Sep 17 00:00:00 2001 From: Bertrand Lorentz Date: Mon, 28 Jul 2025 09:25:45 +0200 Subject: [PATCH 3/3] CHANGELOG: Update with correct dependency version changes --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c27169f..d4632fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ The eForms Core Library is a collection of utilities that are used by our sample This release fixes an issue in the XPathProcessor that could cause a redundant predicate production when contextualising XPaths with multiple predicates. -The versions of various dependencies was updated: ANTLR 4.13.1, JAXB 4.0.4, logback 1.5.3, ph-genericode 7.1.1. +The versions of various dependencies was updated: Apache Commons IO 2.19.0, Apache Commons Lang 3.18.0, Jackson 2.18.3, logback 1.5.18. ## Download