Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# 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.
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

Expand Down
11 changes: 7 additions & 4 deletions src/main/java/eu/europa/ted/eforms/xpath/XPathProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,20 @@ private static String getContextualizedXpath(Queue<XPathStep> 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<String> 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;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down