Git Product home page Git Product logo

efx-toolkit-java's Introduction

๐Ÿ“ Latest Release Notes | ๐Ÿ“ฆ Latest Release Artifacts


Java toolkit for the eForms Expression Language (EFX)

The EFX Toolkit1 for Java developers is a library that enables the transpilation of EFX expressions and templates to different target languages. It also provides an implementation for translating EFX expressions to XPath.

The documentation is available at: https://docs.ted.europa.eu/eforms/latest/efx-toolkit

Using the EFX toolkit1

The EFX toolkit requires Java 11 or later.

It is available as a Maven package on Maven Central and can be used by adding the following to the project's pom.xml.

<dependencies>
  ...
  <dependency>
    <groupId>eu.europa.ted.eforms</groupId>
    <artifactId>efx-toolkit-java</artifactId>
    <version>${efx-toolkit.version}</version>
  </dependency>
  ...
</dependencies>

Replace ${efx-toolkit.version} with the latest version available, or define the corresponding property in your pom.xml.

The documentation describes the capabilities of the library, and the interfaces you might need to implement.

Building

You can build this project as usual using Maven.

The build process uses the grammar files provided in the eForms SDK to generate a parser, using ANTLR4.

In order to be able to use snapshot versions of dependencies, the following should be added to the "profiles" section of the Maven configuration file "settings.xml" (normally under ${HOME}/.m2):

<servers>
  <server>
    <id>ossrh</id>
    <username>${env.MAVEN_USERNAME}</username>
    <password>${env.MAVEN_PASSWORD}</password>
  </server>
</servers>

<profile>
  <id>repositories</id>
  <activation>
    <activeByDefault>true</activeByDefault>
  </activation>
  <repositories>
    <repository>
      <id>ossrh</id>
      <name>OSSRH Snapshots</name>
      <url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
      <releases>
        <enabled>false</enabled>
      </releases>
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
    </repository>
  </repositories>
</profile>

See ".github/workflows/settings.xml".

Testing

Unit tests are available under src/test/java/. They show in particular a variety of EFX expressions and the corresponding XPath expression.

After running the unit tests with mvn test, you can generate a coverage report with mvn jacoco:report. The report is available under target/site/jacoco/, in HTML, CSV, and XML format.

Download

You can download the latest EFX Toolkit from Maven Central.

Maven Central

Footnotes

  1. Copyright 2022 European Union
    Licensed under the EUPL, Version 1.2 or โ€“ as soon they will be approved by the European Commission โ€“ subsequent versions of the EUPL (the "Licence"); You may not use this work except in compliance with the Licence. You may obtain a copy of the Licence here.
    Unless required by applicable law or agreed to in writing, software distributed under the Licence is distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the Licence for the specific language governing permissions and limitations under the Licence. โ†ฉ โ†ฉ2

efx-toolkit-java's People

Contributors

bertrand-lorentz avatar demol-ee avatar lgreulich avatar meletev avatar rouschr avatar rousso avatar vmeloz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Forkers

demol-ee

efx-toolkit-java's Issues

[1.3.0] XPathContextualizer leaves context when child with predicate has same EFX-Context as Parent

The Patches for eForms SDK 1.7.2 introduced a new EFX Semantic, which uses the same context in child elements as their parent do.
This in turn triggers a Bug inside the XPathContextualizer, which will then leave the childs context and instead select all children.

Given the following section of the template view-template/16.efx:

0 {ND-Organization} #{auxiliary|text|roles}: // Roles of this organisation
			0 {ND-Organization[count(for text:$orgid in OPT-200-Organization-Company return OPT-300-Procedure-Buyer[OPT-300-Procedure-Buyer == $orgid])>0]} #{auxiliary|text|buyer} // This org is a Buyer
				{OPP-050-Organization[OPP-050-Organization == TRUE]} #{field|name|OPP-050-Organization} // Leader of the group
				{OPP-052-Organization[OPP-052-Organization == TRUE]} #{field|name|OPP-052-Organization} // CPB Acquiring
				{OPP-051-Organization[OPP-051-Organization == TRUE]} #{field|name|OPP-051-Organization} // CPB Awarding
			{ND-Organization[(some text:$esender in (for text:$orgid in OPT-200-Organization-Company, text:$servprovtype in OPT-030-Procedure-SProvider[OPT-300-Procedure-SProvider == $orgid] return $servprovtype) satisfies $esender == 'serv-prov') or (some text:$esender1 in (for text:$tpoid in OPT-201-Organization-TouchPoint, text:$servprovtype1 in OPT-030-Procedure-SProvider[OPT-300-Procedure-SProvider == $tpoid] return $servprovtype1) satisfies $esender1 == 'serv-prov')]} #{auxiliary|text|organisation-providing-procurement-service} // This org is a Service Provider
			{ND-Organization[(some text:$esender in (for text:$orgid in OPT-200-Organization-Company, text:$servprovtype in OPT-030-Procedure-SProvider[OPT-300-Procedure-SProvider == $orgid] return $servprovtype) satisfies $esender == 'ted-esen') or (some text:$esender1 in (for text:$tpoid in OPT-201-Organization-TouchPoint, text:$servprovtype1 in OPT-030-Procedure-SProvider[OPT-300-Procedure-SProvider == $tpoid] return $servprovtype1) satisfies $esender1 == 'ted-esen')]} #{auxiliary|text|organisation-esender} // This org is an eSender
			{ND-Organization[(OPT-200-Organization-Company == OPT-301-Lot-AddInfo) or (OPT-201-Organization-TouchPoint == OPT-301-Lot-AddInfo)]} #{auxiliary|text|organisation-providing-info-procedure} // Additional Information Providing Organisation (LOT)

Will result in a .xsl of: (which can be reproduced when using f.e. the eforms-notice-viewer in Version 1.8.0, which is the last version supporting EFX 1.0)

 <xsl:template name="block050118"> 
        <section title="block050118"> 
            <span class="label">
                <xsl:value-of select="($labels//entry[@key=concat('auxiliary', '|', 'text', '|', 'roles')]/text(), concat('{', concat('auxiliary', '|', 'text', '|', 'roles'), '}'))[1]"/>
            </span>
            <span class="text">
                <xsl:text>:</xsl:text>
            </span>  
            <xsl:for-each select="../efac:Organization[count(for $orgid in efac:Company/cac:PartyIdentification/cbc:ID/normalize-space(text()) return ../../../../../../cac:ContractingParty/cac:Party/cac:PartyIdentification/cbc:ID[./normalize-space(text()) = $orgid]/normalize-space(text())) &gt; 0]"> 
                <xsl:call-template name="block05011801"/> 
            </xsl:for-each>  
            <xsl:for-each select="../efac:Organization[(some $esender in (for $orgid in efac:Company/cac:PartyIdentification/cbc:ID/normalize-space(text()), $servprovtype in ../../../../../../cac:ContractingParty/cac:Party/cac:ServiceProviderParty/cbc:ServiceTypeCode[../cac:Party/cac:PartyIdentification/cbc:ID/normalize-space(text()) = $orgid]/normalize-space(text()) return $servprovtype) satisfies $esender = 'serv-prov') or (some $esender1 in (for $tpoid in efac:TouchPoint/cac:PartyIdentification/cbc:ID/normalize-space(text()), $servprovtype1 in ../../../../../../cac:ContractingParty/cac:Party/cac:ServiceProviderParty/cbc:ServiceTypeCode[../cac:Party/cac:PartyIdentification/cbc:ID/normalize-space(text()) = $tpoid]/normalize-space(text()) return $servprovtype1) satisfies $esender1 = 'serv-prov')]"> 
                <xsl:call-template name="block05011802"/> 
            </xsl:for-each>  
            <xsl:for-each select="../efac:Organization[(some $esender in (for $orgid in efac:Company/cac:PartyIdentification/cbc:ID/normalize-space(text()), $servprovtype in ../../../../../../cac:ContractingParty/cac:Party/cac:ServiceProviderParty/cbc:ServiceTypeCode[../cac:Party/cac:PartyIdentification/cbc:ID/normalize-space(text()) = $orgid]/normalize-space(text()) return $servprovtype) satisfies $esender = 'ted-esen') or (some $esender1 in (for $tpoid in efac:TouchPoint/cac:PartyIdentification/cbc:ID/normalize-space(text()), $servprovtype1 in ../../../../../../cac:ContractingParty/cac:Party/cac:ServiceProviderParty/cbc:ServiceTypeCode[../cac:Party/cac:PartyIdentification/cbc:ID/normalize-space(text()) = $tpoid]/normalize-space(text()) return $servprovtype1) satisfies $esender1 = 'ted-esen')]"> 
                <xsl:call-template name="block05011803"/> 
            </xsl:for-each>  
            <xsl:for-each select="../efac:Organization[(efac:Company/cac:PartyIdentification/cbc:ID/normalize-space(text()) = ../../../../../../cac:ProcurementProjectLot[cbc:ID/@schemeName='Lot']/cac:TenderingTerms/cac:AdditionalInformationParty/cac:PartyIdentification/cbc:ID/normalize-space(text())) or (efac:TouchPoint/cac:PartyIdentification/cbc:ID/normalize-space(text()) = ../../../../../../cac:ProcurementProjectLot[cbc:ID/@schemeName='Lot']/cac:TenderingTerms/cac:AdditionalInformationParty/cac:PartyIdentification/cbc:ID/normalize-space(text()))]"> 
                <xsl:call-template name="block05011804"/> 
....
        </section> 
    </xsl:template> 

Because of a Bug inside the XPathContextualizer, the generated XPath will leave the block's context:
<xsl:for-each select="../efac:Organization[count(for $orgid in...]...
In this case, it should be : <xsl:for-each select=".[count(for $orgid in...]...

Which in turn will break the selector, because all children of the parent element will be selected, instead of the current one.

This has been corrected with commit 2d43d81, however this fix is only available inside the 2.0.0 alpha releases, which we can't use yet. Right now, all view-templates are broken because of this Bug.

Are there any plans, to release a 1.3.1 Version of the efx-toolkit, to fix this behaviour?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.