call method

  1. @override
XPathSequence call(
  1. XPathContext context,
  2. List<XPathSequence> arguments
)
override

Invokes the function item with the given arguments.

Implementation

@override
XPathSequence call(XPathContext context, List<XPathSequence> arguments) {
  if (arguments.length != 1) {
    throw XPathEvaluationException(
      XPathErrorCode.FOAP0001,
      'Maps expect exactly 1 argument, but got ${arguments.length}',
    );
  }
  final key = arguments.single.atomize().firstOrNull;
  if (key == null) {
    throw XPathEvaluationException(
      XPathErrorCode.XPTY0004,
      'Map key cannot be empty sequence',
    );
  }
  return get(key) ?? XPathSequence.empty;
}