An EDI interchange, an HL7 message or an XML file is one document: a header, a run of records, maybe a footer. When two documents flow into one output, something has to decide whether they are written as two framed documents or one. That is the Envelope node's job. Change the settings and see the documents the Sink writes. For what $doc.* sections are and how documents start, see Document context first.
reconstruct_envelope: trueRows are id,tag: a Transform before the Envelope emits tag = $doc.interchange.tag, so each row keeps its own document's tag even after concat. The footer row is the interchange section, rendered by the Sink's footer_from_doc: interchange; a document without that section gets no footer row.
- type: aggregate
name: per_category
input: sources
config:
group_by: [category]
cxl: |
emit n = count(*)
Aggregate rows belong to no document: they carry no header, no $doc.* values and no source file. A Sink with reconstruct_envelope: true writes them with no header or footer, and today a concat Envelope placed after the Aggregate does not change that, although it plans without error (#603). Reshape output is the same (#1317).
X12, EDIFACT, HL7 and SWIFT output frame exactly one document per file, so a body that could hold two documents must be consolidated first (E355). A Sink with reconstruct_envelope: true needs every row to belong to a document, so rows from a Combine, Aggregate or Composition must pass through a concat Envelope first (E347). E347 has three other forms — per-file split: or {source_file} paths, dlq_granularity: document, and correlation_key — see clinker explain --code E347.