diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 6b11035..4c5c702 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -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: diff --git a/src/main/java/eu/europa/ted/efx/xpath/XPathScriptGenerator.java b/src/main/java/eu/europa/ted/efx/xpath/XPathScriptGenerator.java index 83b3c82..2756258 100644 --- a/src/main/java/eu/europa/ted/efx/xpath/XPathScriptGenerator.java +++ b/src/main/java/eu/europa/ted/efx/xpath/XPathScriptGenerator.java @@ -83,10 +83,7 @@ public 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); diff --git a/src/test/java/eu/europa/ted/efx/EfxExpressionTranslatorTest.java b/src/test/java/eu/europa/ted/efx/EfxExpressionTranslatorTest.java index 6fea719..6a95ef7 100644 --- a/src/test/java/eu/europa/ted/efx/EfxExpressionTranslatorTest.java +++ b/src/test/java/eu/europa/ted/efx/EfxExpressionTranslatorTest.java @@ -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 @@ -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