filter method
List<TreeReference>
filter(
- DataInstance sourceInstance,
- TreeReference nodeset,
- XPathExpression predicate,
- List<
TreeReference> children, - EvaluationContext context,
- List<
TreeReference> next(),
override
The children of nodeset that pass predicate, or the result of
next (the rest of the chain) when this strategy doesn't apply.
Implementation
@override
List<TreeReference> filter(
DataInstance sourceInstance,
TreeReference nodeset,
XPathExpression predicate,
List<TreeReference> children,
EvaluationContext context,
List<TreeReference> Function() next,
) {
if (sourceInstance.instanceId == null) return next();
final candidate = CompareToNodeExpression.parse(predicate);
if (candidate != null) {
return _cached(
_key(sourceInstance, nodeset, predicate, context, candidate),
next,
);
}
if (predicate is XPathBoolExpr) {
final candidateA = CompareToNodeExpression.parse(predicate.a);
final candidateB = CompareToNodeExpression.parse(predicate.b);
if (candidateA != null && candidateB != null) {
final key =
'XPathBoolExpr:${predicate.op}'
'${_key(sourceInstance, nodeset, predicate.a, context, candidateA)}'
'${_key(sourceInstance, nodeset, predicate.b, context, candidateB)}';
return _cached(key, next);
}
}
return next();
}