Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/main/java/eu/europa/ted/efx/interfaces/ScriptGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,17 @@ public PathExpression composeNodeReferenceWithPredicate(
public PathExpression composeFieldReferenceWithPredicate(
final PathExpression fieldReference, final BooleanExpression predicate);

public PathExpression composeFieldReferenceWithAxis(final PathExpression fieldReference,
final String axis);
/**
* Applies an XPath axis to a field reference.
*
* @deprecated Axis syntax has been removed from EFX-2. This method is only used by EFX-1
* and will be removed in a future version.
*/
@Deprecated(forRemoval = true)
default PathExpression composeFieldReferenceWithAxis(final PathExpression fieldReference,
final String axis) {
return fieldReference;
}

/**
* Given a PathExpression, this method should return the target language script for retrieving the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ public XPathScriptGeneratorV1(TranslatorOptions translatorOptions) {
super(translatorOptions);
}

@Override
public PathExpression composeFieldReferenceWithAxis(final PathExpression fieldReference,
final String axis) {
String resultXPath = XPathProcessor.addAxis(axis, fieldReference.getScript());
return Expression.instantiate(resultXPath, fieldReference.getClass());
}

@Override
public StringExpression composeToStringConversion(NumericExpression number) {
String formatString = this.translatorOptions.getDecimalFormat().adaptFormatString("0.##########");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,14 +269,14 @@ protected String getFieldId(AbsoluteFieldReferenceContext ctx) {
if (ctx == null) {
return null;
}
return this.getFieldId(ctx.reference.reference.linkedFieldReference());
return this.getFieldId(ctx.reference.reference);
}

protected String getFieldId(FieldReferenceInOtherNoticeContext ctx) {
if (ctx == null) {
return null;
}
return this.getFieldId(ctx.reference.reference.reference.reference.reference.linkedFieldReference());
return this.getFieldId(ctx.reference.reference.reference.reference.reference);
}

protected String getFieldId(FieldContextContext ctx) {
Expand All @@ -300,7 +300,7 @@ protected String getFieldId(FieldReferenceWithPredicateContext ctx) {
if (ctx == null) {
return null;
}
return this.getFieldId(ctx.fieldReferenceWithAxis().linkedFieldReference());
return this.getFieldId(ctx.linkedFieldReference());
}

protected static String getNodeId(NodeReferenceContext ctx) {
Expand Down Expand Up @@ -1315,14 +1315,6 @@ public void exitPredicate(PredicateContext ctx) {
this.efxContext.pop();
}

@Override
public void exitFieldReferenceWithAxis(FieldReferenceWithAxisContext ctx) {
if (ctx.axis() != null) {
this.stack.push(this.script.composeFieldReferenceWithAxis(
this.stack.pop(PathExpression.class), ctx.axis().Axis().getText()));
}
}

// #endregion References with Predicates ------------------------------------

// #region External References ----------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@

import eu.europa.ted.eforms.sdk.component.SdkComponent;
import eu.europa.ted.eforms.sdk.component.SdkComponentType;
import eu.europa.ted.eforms.xpath.XPathProcessor;
import eu.europa.ted.efx.interfaces.ScriptGenerator;
import eu.europa.ted.efx.interfaces.TranslatorOptions;
import eu.europa.ted.efx.model.expressions.Expression;
Expand Down Expand Up @@ -96,13 +95,6 @@ public PathExpression composeFieldReferenceWithPredicate(PathExpression fieldRef
return Expression.instantiate(fieldReference.getScript() + '[' + predicate.getScript() + ']', fieldReference.getClass());
}

@Override
public PathExpression composeFieldReferenceWithAxis(final PathExpression fieldReference,
final String axis) {
String resultXPath = XPathProcessor.addAxis(axis, fieldReference.getScript());
return Expression.instantiate(resultXPath, fieldReference.getClass());
}

@Override
public PathExpression composeFieldValueReference(PathExpression fieldReference) {
if (fieldReference.is(EfxDataType.String.class)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1225,12 +1225,6 @@ void testFieldReference_ForDurationFields() {
"ND-Root", "BT-00-Measure");
}

@Test
void testFieldReference_WithAxis() {
testExpressionTranslationWithContext("./preceding::PathNode/IntegerField/number()", "ND-Root",
"ND-Root::preceding::integerField");
}

/**
* Unlike EFX-1, where any reference to a text-multilingual field, is automatically translated to
* an expression that returns the value of the field in the preferred language, in EFX-2 there are
Expand Down