Skip to content

Commit 19c4166

Browse files
authored
Merge pull request #87 from OP-TED/develop
EXT-1.3.0: Simplified text-multilingual rendering
2 parents 49d3d28 + a499d31 commit 19c4166

File tree

3 files changed

+19
-10
lines changed

3 files changed

+19
-10
lines changed

.github/workflows/publish.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ jobs:
2121
steps:
2222
- uses: actions/checkout@v3
2323
- name: Import GPG Key
24-
uses: crazy-max/ghaction-import-gpg@v1
25-
env:
26-
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
27-
PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
24+
uses: crazy-max/ghaction-import-gpg@v5
25+
with:
26+
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
27+
passphrase: ${{ secrets.GPG_PASSPHRASE }}
2828
- name: Set up Java for publishing to Maven Central Repository
2929
uses: actions/setup-java@v3
3030
with:

src/main/java/eu/europa/ted/efx/xpath/XPathScriptGenerator.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,7 @@ public <T extends Expression> T composeFieldValueReference(PathExpression fieldR
8383
if ((MultilingualStringExpression.class.isAssignableFrom(type)
8484
|| MultilingualStringListExpression.class.isAssignableFrom(type))
8585
&& !XPathContextualizer.hasPredicate(fieldReference, "@languageID")) {
86-
PathExpression languageSpecific = XPathContextualizer.addPredicate(fieldReference, "@languageID=$__LANG__");
87-
String script = "(for $__LANG__ in $PREFERRED_LANGUAGES return " + languageSpecific.script
88-
+ "/normalize-space(text()), " + fieldReference.script + "/normalize-space(text()))[1]";
89-
return Expression.instantiate(script, type);
86+
return Expression.instantiate("efx:preferred-language-text(" + fieldReference.script + ")", type);
9087
}
9188
if (StringExpression.class.isAssignableFrom(type) || StringListExpression.class.isAssignableFrom(type)) {
9289
return Expression.instantiate(fieldReference.script + "/normalize-space(text())", type);

src/test/java/eu/europa/ted/efx/EfxExpressionTranslatorTest.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ void testLikePatternCondition_WithNot() {
9797
@Test
9898
void testFieldValueComparison_UsingTextFields() {
9999
assertEquals(
100-
"(for $__LANG__ in $PREFERRED_LANGUAGES return PathNode/TextMultilingualField[@languageID=$__LANG__]/normalize-space(text()), PathNode/TextMultilingualField/normalize-space(text()))[1]",
101-
test("ND-Root", "BT-00-Text-Multilingual"));
100+
"PathNode/TextField/normalize-space(text()) = efx:preferred-language-text(PathNode/TextMultilingualField)",
101+
test("ND-Root", "BT-00-Text == BT-00-Text-Multilingual"));
102102
}
103103

104104
@Test
@@ -1076,6 +1076,18 @@ void testFieldReference_WithAxis() {
10761076
test("ND-Root", "ND-Root::preceding::BT-00-Integer"));
10771077
}
10781078

1079+
@Test
1080+
void testMultilingualTextFieldReference() {
1081+
assertEquals("efx:preferred-language-text(PathNode/TextMultilingualField)",
1082+
test("ND-Root", "BT-00-Text-Multilingual"));
1083+
}
1084+
1085+
@Test
1086+
void testMultilingualTextFieldReference_WithLanguagePredicate() {
1087+
assertEquals("PathNode/TextMultilingualField[./@languageID = 'eng']/normalize-space(text())",
1088+
test("ND-Root", "BT-00-Text-Multilingual[BT-00-Text-Multilingual/@languageID == 'eng']"));
1089+
}
1090+
10791091
/*** Boolean functions ***/
10801092

10811093
@Test

0 commit comments

Comments
 (0)