Publisherintermediate

RTF Templates & Word Plugin Syntax

Explain how BI Publisher's RTF template syntax (for-each loops, conditionals, placeholders) is embedded in Microsoft Word to produce data-driven documents.

RTF templates are the most common way business users and report developers build BI Publisher layouts, because they let you design in familiar Microsoft Word rather than a specialized tool — but the syntax embedded in that Word document is doing real programming-like work, and interviewers probe this to see whether a candidate has actually built templates, not just viewed finished reports.

It's like a mail-merge letter in Word where you don't just insert a name field — you can also tell Word "repeat this paragraph once for every item in their order" and "only show this line if their balance is overdue," all directly inside the same familiar document you're already editing.

Key Concepts

1
The BI Publisher Template Builder plugin for Word adds a ribbon that inserts special field codes (visually shown as gray-shaded text, technically stored as hidden form-field codes or bracketed syntax like <?FIELD_NAME?>) directly into the document at the position where that data should render. Simple placeholders just echo a single XML element's value, but the real power comes from repeating groups: wrapping a table row (or any repeatable section) with <?for-each:GROUP_NAME?> ... <?end for-each?> tells the engine to repeat that section once per occurrence of GROUP_NAME in the data model's XML — this is how a single-row template becomes a multi-line invoice table.
BI Publisher Template Builderrepeating groups<?FIELD_NAME?><?for-each:GROUP_NAME?> ... <?end for-each?>GROUP_NAME
2
Conditional formatting uses <?if:condition?> ... <?end if?> blocks to show/hide content (e.g., only print a "PAST DUE" stamp <?if:DAYS_OVERDUE > 30?>), and sorting/grouping within a for-each loop can nest additional groupings (e.g., group invoice lines by product category within the invoice). Page-level features like conditional page breaks (<?split-by-page-break:?>), running totals, and cross-tab/pivot-style layouts are also achievable, though they require more advanced syntax and interviewers reserve these for probing truly hands-on experience.
Conditional formattingsorting/grouping<?if:condition?> ... <?end if?><?if:DAYS_OVERDUE > 30?><?split-by-page-break:?>
3
A practical detail worth mentioning: templates should be built and tested against sample XML data exported directly from the actual data model (not hand-typed fake data), since field names and nesting must match exactly, and mismatches are a very common source of "blank field" bugs in production templates.
sample XML data