Skip to content

Commit

Permalink
Use XPathProcessor for all remaining XPath operations
Browse files Browse the repository at this point in the history
The XPathContextualizer class is only kept to provide utility method
to box and unbox XPath strings into PathExpression instances, and just
uses XPathProcessor from eforms-core-java.

Remove the XPathContextualizerTest class, as all those unit tests are
now unit tests of XPathProcessor.
  • Loading branch information
bertrand-lorentz committed Oct 12, 2023
1 parent b380249 commit 70895ab
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 559 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

import eu.europa.ted.eforms.sdk.component.SdkComponent;
import eu.europa.ted.eforms.sdk.component.SdkComponentType;
import eu.europa.ted.eforms.xpath.XPathInfo;
import eu.europa.ted.eforms.xpath.XPathProcessor;
import eu.europa.ted.efx.interfaces.TranslatorOptions;
import eu.europa.ted.efx.model.expressions.path.PathExpression;
import eu.europa.ted.efx.model.types.EfxDataType;
import eu.europa.ted.efx.xpath.XPathContextualizer;
import eu.europa.ted.efx.xpath.XPathScriptGenerator;

@SdkComponent(versions = {"1"}, componentType = SdkComponentType.SCRIPT_GENERATOR)
Expand Down Expand Up @@ -40,7 +41,8 @@ public XPathScriptGeneratorV1(TranslatorOptions translatorOptions) {
*/
@Override
public PathExpression composeFieldValueReference(PathExpression fieldReference) {
if (fieldReference.is(EfxDataType.MultilingualString.class) && !XPathContextualizer.hasPredicate(fieldReference, "@languageID")) {
XPathInfo xpathInfo = XPathProcessor.parse(fieldReference.getScript());
if (fieldReference.is(EfxDataType.MultilingualString.class) && !xpathInfo.hasPredicate("@languageID")) {
return PathExpression.instantiate("efx:preferred-language-text(" + fieldReference.getScript() + ")", fieldReference.getDataType());
}
return super.composeFieldValueReference(fieldReference);
Expand Down
Loading

0 comments on commit 70895ab

Please sign in to comment.