startChunkedConversion method

  1. @override
StringConversionSink startChunkedConversion(
  1. Sink<List<XmlEvent>> sink
)
override

Starts a chunked conversion.

The returned sink serves as input for the long-running conversion. The given sink serves as output.

Implementation

@override
StringConversionSink startChunkedConversion(Sink<List<XmlEvent>> sink) {
  final annotator = XmlAnnotator(
    validateDocument: validateDocument,
    validateNamespace: validateNamespace,
    validateNesting: validateNesting,
    validateAttributes: validateAttributes,
    withBuffer: false,
    withLocation: withLocation,
    withNamespace: withNamespace,
    withParent: withParent,
  );
  return ParseDecoderSink<XmlEvent>(
    eventParserCache[entityMapping],
    sink,
    onMatch: (event, {required start, required stop, required buffer}) {
      annotator.annotate(event, start: start, stop: stop);
    },
    onError: (failure) {
      throw XmlParserException(failure.message, position: failure.position);
    },
    onClose: ({required position, required buffer}) {
      annotator.close(position: position);
    },
  );
}