Clinker user guide · ← Envelope Nodes

How many
documents?

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.

01

Preserve or concatTwo input documents, one CSV output with reconstruct_envelope: true

Inputs

Their headers
Envelope node
footer:

    

What the Sink writes

Rows 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.

02

And an AggregateCount rows per category after the Envelope

a.csv · x, x, yb.csv · x, x, x
Envelope node
- type: aggregate
  name: per_category
  input: sources
  config:
    group_by: [category]
    cxl: |
      emit n = count(*)

Aggregate output

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).

03

Will it plan?The two checks that guard framed output

Input
Before the Envelope
Envelope node
Output

    

Outcome

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.