From 044cbf4599658d7c21772e0ef3de99a2eb6084ff Mon Sep 17 00:00:00 2001 From: Ioannis Rousochatzakis Date: Wed, 20 Dec 2023 23:45:50 +0100 Subject: [PATCH 1/7] Updated pom.xml after merging from main into develop. --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index bfd0d30..70f4cd7 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ eu.europa.ted.eforms efx-toolkit-java - 2.0.0-alpha.2 + 2.0.0-SNAPSHOT jar EFX Toolkit for Java @@ -59,7 +59,7 @@ ${project.build.directory}/eforms-sdk/antlr4 - 1.3.0 + 1.3.0-SNAPSHOT 4.9.3 From 546248389d2e785c7f2b85684c1c94886ee0ac81 Mon Sep 17 00:00:00 2001 From: Ioannis Rousochatzakis Date: Wed, 20 Dec 2023 23:51:37 +0100 Subject: [PATCH 2/7] Updated eforms-core-library dependency in pom.xml --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 70f4cd7..d626baa 100644 --- a/pom.xml +++ b/pom.xml @@ -59,7 +59,7 @@ ${project.build.directory}/eforms-sdk/antlr4 - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT 4.9.3 From babbf9537a10dfb71cf673181fc4e4c0e41f0f1e Mon Sep 17 00:00:00 2001 From: Ioannis Rousochatzakis Date: Wed, 14 Feb 2024 00:05:31 +0100 Subject: [PATCH 3/7] Fixes #88. Date and time formatting now works correctly with sequences. --- .../ted/efx/sdk1/EfxTemplateTranslatorV1.java | 27 +++++++++++++++++-- .../ted/efx/sdk2/EfxTemplateTranslatorV2.java | 26 ++++++++++++++++-- .../efx/sdk1/EfxTemplateTranslatorV1Test.java | 8 +++--- 3 files changed, 53 insertions(+), 8 deletions(-) diff --git a/src/main/java/eu/europa/ted/efx/sdk1/EfxTemplateTranslatorV1.java b/src/main/java/eu/europa/ted/efx/sdk1/EfxTemplateTranslatorV1.java index 9880486..1c3c1d0 100644 --- a/src/main/java/eu/europa/ted/efx/sdk1/EfxTemplateTranslatorV1.java +++ b/src/main/java/eu/europa/ted/efx/sdk1/EfxTemplateTranslatorV1.java @@ -29,8 +29,11 @@ import eu.europa.ted.efx.model.expressions.TypedExpression; import eu.europa.ted.efx.model.expressions.path.PathExpression; import eu.europa.ted.efx.model.expressions.path.StringPathExpression; +import eu.europa.ted.efx.model.expressions.scalar.DateExpression; import eu.europa.ted.efx.model.expressions.scalar.StringExpression; +import eu.europa.ted.efx.model.expressions.sequence.DateSequenceExpression; import eu.europa.ted.efx.model.expressions.sequence.StringSequenceExpression; +import eu.europa.ted.efx.model.expressions.sequence.TimeSequenceExpression; import eu.europa.ted.efx.model.templates.ContentBlock; import eu.europa.ted.efx.model.templates.ContentBlockStack; import eu.europa.ted.efx.model.templates.Markup; @@ -496,9 +499,29 @@ public void exitStandardExpressionBlock(StandardExpressionBlockContext ctx) { // functions. if (TypedExpression.class.isAssignableFrom(expression.getClass())) { if (EfxDataType.Date.class.isAssignableFrom(((TypedExpression) expression).getDataType())) { - expression = new StringExpression("format-date(" + expression.getScript() + ", '[D01]/[M01]/[Y0001]')"); + + var loopVariable = new Variable("item", + this.script.composeVariableDeclaration("item", DateExpression.class), DateExpression.empty(), + this.script.composeVariableReference("item", DateExpression.class)); + + expression = this.script.composeForExpression( + this.script.composeIteratorList( + List.of(this.script.composeIteratorExpression(loopVariable.declarationExpression, + new DateSequenceExpression(expression.getScript())))), + new StringExpression("format-date($item, '[D01]/[M01]/[Y0001]')"), + StringSequenceExpression.class); } else if (EfxDataType.Time.class.isAssignableFrom(((TypedExpression) expression).getDataType())) { - expression = new StringExpression("format-time(" + expression.getScript() + ", '[H01]:[m01] [Z]')"); + + var loopVariable = new Variable("item", + this.script.composeVariableDeclaration("item", DateExpression.class), DateExpression.empty(), + this.script.composeVariableReference("item", DateExpression.class)); + + expression = this.script.composeForExpression( + this.script.composeIteratorList( + List.of(this.script.composeIteratorExpression(loopVariable.declarationExpression, + new TimeSequenceExpression(expression.getScript())))), + new StringExpression("format-time($item, '[H01]:[m01] [Z]')"), + StringSequenceExpression.class); } } diff --git a/src/main/java/eu/europa/ted/efx/sdk2/EfxTemplateTranslatorV2.java b/src/main/java/eu/europa/ted/efx/sdk2/EfxTemplateTranslatorV2.java index ccd9e19..8d87234 100644 --- a/src/main/java/eu/europa/ted/efx/sdk2/EfxTemplateTranslatorV2.java +++ b/src/main/java/eu/europa/ted/efx/sdk2/EfxTemplateTranslatorV2.java @@ -38,7 +38,9 @@ import eu.europa.ted.efx.model.expressions.scalar.ScalarExpression; import eu.europa.ted.efx.model.expressions.scalar.StringExpression; import eu.europa.ted.efx.model.expressions.scalar.TimeExpression; +import eu.europa.ted.efx.model.expressions.sequence.DateSequenceExpression; import eu.europa.ted.efx.model.expressions.sequence.StringSequenceExpression; +import eu.europa.ted.efx.model.expressions.sequence.TimeSequenceExpression; import eu.europa.ted.efx.model.templates.ContentBlock; import eu.europa.ted.efx.model.templates.ContentBlockStack; import eu.europa.ted.efx.model.templates.Markup; @@ -559,9 +561,29 @@ public void exitStandardExpressionBlock(StandardExpressionBlockContext ctx) { // functions. if (TypedExpression.class.isAssignableFrom(expression.getClass())) { if (EfxDataType.Date.class.isAssignableFrom(((TypedExpression) expression).getDataType())) { - expression = new StringExpression("format-date(" + expression.getScript() + ", '[D01]/[M01]/[Y0001]')"); + + var loopVariable = new Variable("item", + this.script.composeVariableDeclaration("item", DateExpression.class), DateExpression.empty(), + this.script.composeVariableReference("item", DateExpression.class)); + + expression = this.script.composeForExpression( + this.script.composeIteratorList( + List.of(this.script.composeIteratorExpression(loopVariable.declarationExpression, + new DateSequenceExpression(expression.getScript())))), + new StringExpression("format-date($item, '[D01]/[M01]/[Y0001]')"), + StringSequenceExpression.class); } else if (EfxDataType.Time.class.isAssignableFrom(((TypedExpression) expression).getDataType())) { - expression = new StringExpression("format-time(" + expression.getScript() + ", '[H01]:[m01] [Z]')"); + + var loopVariable = new Variable("item", + this.script.composeVariableDeclaration("item", DateExpression.class), DateExpression.empty(), + this.script.composeVariableReference("item", DateExpression.class)); + + expression = this.script.composeForExpression( + this.script.composeIteratorList( + List.of(this.script.composeIteratorExpression(loopVariable.declarationExpression, + new TimeSequenceExpression(expression.getScript())))), + new StringExpression("format-time($item, '[H01]:[m01] [Z]')"), + StringSequenceExpression.class); } } diff --git a/src/test/java/eu/europa/ted/efx/sdk1/EfxTemplateTranslatorV1Test.java b/src/test/java/eu/europa/ted/efx/sdk1/EfxTemplateTranslatorV1Test.java index 4e2c45e..02153f6 100644 --- a/src/test/java/eu/europa/ted/efx/sdk1/EfxTemplateTranslatorV1Test.java +++ b/src/test/java/eu/europa/ted/efx/sdk1/EfxTemplateTranslatorV1Test.java @@ -353,11 +353,11 @@ void testEndOfLineComments() { @Test void testImplicitFormatting_Dates() { - assertEquals("let block01() -> { eval(format-date(PathNode/StartDateField/xs:date(text()), '[D01]/[M01]/[Y0001]')) }\nfor-each(/*).call(block01())", translateTemplate("{ND-Root} ${BT-00-StartDate}")); - } + assertEquals("let block01() -> { eval(for $item in PathNode/StartDateField/xs:date(text()) return format-date($item, '[D01]/[M01]/[Y0001]')) }\nfor-each(/*).call(block01())", translateTemplate("{ND-Root} ${BT-00-StartDate}")); + } @Test void testImplicitFormatting_Times() { - assertEquals("let block01() -> { eval(format-time(PathNode/StartTimeField/xs:time(text()), '[H01]:[m01] [Z]')) }\nfor-each(/*).call(block01())", translateTemplate("{ND-Root} ${BT-00-StartTime}")); - } + assertEquals("let block01() -> { eval(for $item in PathNode/StartTimeField/xs:time(text()) return format-time($item, '[H01]:[m01] [Z]')) }\nfor-each(/*).call(block01())", translateTemplate("{ND-Root} ${BT-00-StartTime}")); + } } From befeb398f1cf61596212ef5126a8e1c839351e03 Mon Sep 17 00:00:00 2001 From: Ioannis Rousochatzakis Date: Thu, 15 Feb 2024 00:55:29 +0100 Subject: [PATCH 4/7] Updated pom.xml to 2.0.0-alpha.3 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index d626baa..f849c74 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ eu.europa.ted.eforms efx-toolkit-java - 2.0.0-SNAPSHOT + 2.0.0-alpha.3 jar EFX Toolkit for Java From 06367177ef7a76ed83d6138c840cd9e1cfa63dd6 Mon Sep 17 00:00:00 2001 From: Ioannis Rousochatzakis Date: Thu, 15 Feb 2024 00:56:06 +0100 Subject: [PATCH 5/7] Updated the changelog --- CHANGELOG.md | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dc2266f..b4313b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -# EFX Toolkit 2.0.0-alpha.2 Release Notes +# EFX Toolkit 2.0.0-alpha.3 Release Notes _The EFX Toolkit for Java developers is a library that enables the transpilation of [EFX](https://docs.ted.europa.eu/eforms/latest/efx) expressions and templates to different target languages. It also includes an implementation of an EFX-to-XPath transpiler._ @@ -6,16 +6,8 @@ _The EFX Toolkit for Java developers is a library that enables the transpilation ## In this release -This release improves translation of EFX-1 templates as follows: - -- Renders sequences of labels when a sequence expression is used to provide asset-ids. -- Renders distinct labels from sequences. -- Improves date and time formatting. - -This release also includes a refactoring that moved XPath processing classes to the eForms Core Library 1.2.0 to improve reusability. - -There are no changes in EFX-2 translation included in this release. - +This release fixes an a bug that caused an exception to be thrown by XSLT processors when trying to format sequences of dates or times. +This bug was reported by a user in OPT-TED/eforms-notice-viewer#88. ## EFX-1 Support From f98653f5acb2a27eedb6330bd778e4fd584259f5 Mon Sep 17 00:00:00 2001 From: Ioannis Rousochatzakis Date: Thu, 15 Feb 2024 00:58:07 +0100 Subject: [PATCH 6/7] Fixed hyperlink in changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b4313b0..b78fa14 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ _The EFX Toolkit for Java developers is a library that enables the transpilation ## In this release This release fixes an a bug that caused an exception to be thrown by XSLT processors when trying to format sequences of dates or times. -This bug was reported by a user in OPT-TED/eforms-notice-viewer#88. +This bug was reported by a user in [eForms Notice Viewer issue #88](https://github.com/OP-TED/eforms-notice-viewer/issues/88). ## EFX-1 Support From de778512765a4fffb5036fae715b02db2cb23b13 Mon Sep 17 00:00:00 2001 From: Yannis Rousochatzakis <91379+rousso@users.noreply.github.com> Date: Thu, 15 Feb 2024 16:10:24 +0100 Subject: [PATCH 7/7] Update pom.xml --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f849c74..d50786a 100644 --- a/pom.xml +++ b/pom.xml @@ -59,7 +59,7 @@ ${project.build.directory}/eforms-sdk/antlr4 - 1.4.0-SNAPSHOT + 1.3.0 4.9.3