Skip to content

Commit

Permalink
Merge pull request #87 from OP-TED/develop
Browse files Browse the repository at this point in the history
EXT-1.3.0: Simplified text-multilingual rendering
  • Loading branch information
rousso authored Jul 25, 2023
2 parents 49d3d28 + a499d31 commit 19c4166
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Import GPG Key
uses: crazy-max/ghaction-import-gpg@v1
env:
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
uses: crazy-max/ghaction-import-gpg@v5
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}
- name: Set up Java for publishing to Maven Central Repository
uses: actions/setup-java@v3
with:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,7 @@ public <T extends Expression> T composeFieldValueReference(PathExpression fieldR
if ((MultilingualStringExpression.class.isAssignableFrom(type)
|| MultilingualStringListExpression.class.isAssignableFrom(type))
&& !XPathContextualizer.hasPredicate(fieldReference, "@languageID")) {
PathExpression languageSpecific = XPathContextualizer.addPredicate(fieldReference, "@languageID=$__LANG__");
String script = "(for $__LANG__ in $PREFERRED_LANGUAGES return " + languageSpecific.script
+ "/normalize-space(text()), " + fieldReference.script + "/normalize-space(text()))[1]";
return Expression.instantiate(script, type);
return Expression.instantiate("efx:preferred-language-text(" + fieldReference.script + ")", type);
}
if (StringExpression.class.isAssignableFrom(type) || StringListExpression.class.isAssignableFrom(type)) {
return Expression.instantiate(fieldReference.script + "/normalize-space(text())", type);
Expand Down
16 changes: 14 additions & 2 deletions src/test/java/eu/europa/ted/efx/EfxExpressionTranslatorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ void testLikePatternCondition_WithNot() {
@Test
void testFieldValueComparison_UsingTextFields() {
assertEquals(
"(for $__LANG__ in $PREFERRED_LANGUAGES return PathNode/TextMultilingualField[@languageID=$__LANG__]/normalize-space(text()), PathNode/TextMultilingualField/normalize-space(text()))[1]",
test("ND-Root", "BT-00-Text-Multilingual"));
"PathNode/TextField/normalize-space(text()) = efx:preferred-language-text(PathNode/TextMultilingualField)",
test("ND-Root", "BT-00-Text == BT-00-Text-Multilingual"));
}

@Test
Expand Down Expand Up @@ -1076,6 +1076,18 @@ void testFieldReference_WithAxis() {
test("ND-Root", "ND-Root::preceding::BT-00-Integer"));
}

@Test
void testMultilingualTextFieldReference() {
assertEquals("efx:preferred-language-text(PathNode/TextMultilingualField)",
test("ND-Root", "BT-00-Text-Multilingual"));
}

@Test
void testMultilingualTextFieldReference_WithLanguagePredicate() {
assertEquals("PathNode/TextMultilingualField[./@languageID = 'eng']/normalize-space(text())",
test("ND-Root", "BT-00-Text-Multilingual[BT-00-Text-Multilingual/@languageID == 'eng']"));
}

/*** Boolean functions ***/

@Test
Expand Down

0 comments on commit 19c4166

Please sign in to comment.