How can we help you?

XSLT Conditions and Repeating Content

Product: FeraRender Topic: Template Authoring Versions: Applies to all documented versions Current

Generate optional sections and repeated rows from XML.

Audience: Template authors
Recommended visibility: Public

Overview

Generate optional sections and repeated rows from XML. Author templates against a documented data contract and a known-good base package. Keep source files, sample data, and expected output together.

Key points

  • Use xsl:if for a single optional branch.
  • Use xsl:choose for mutually exclusive alternatives.
  • Use xsl:for-each for repeated records.
  • Keep assignment-level conditions inside fragment XSLT because assignment conditions are not yet compiled.
  • Test zero, one, and many records.

Example

<xsl:if test="/data/Matter/caseNumber != ''">
  <w:p>
    <w:r>
      <w:t><xsl:value-of select="/data/Matter/caseNumber"/></w:t>
    </w:r>
  </w:p>
</xsl:if>

<xsl:for-each select="/data/Items/Item">
  <w:p>
    <w:r><w:t><xsl:value-of select="description"/></w:t></w:r>
  </w:p>
</xsl:for-each>

Replace bracketed values with values issued for the target environment. Never place production tokens, API keys, or client data in screenshots or public examples.

Recommended procedure

  1. Prepare sample XML that includes optional and repeated data.
  2. Author the smallest valid transform or fragment.
  3. Validate placeholders, XPath, XML, XSLT, and OpenXML structure.
  4. Render and compare the result with the expected document.

Authoring checklist

  • Keep the source template under version control or in an approved source library.
  • Keep sanitized sample XML next to the template.
  • Test missing, long, repeated, and special-character values.
  • Validate both the transform and the final DOCX or PDF.
  • Document every external style, font, image, relationship, or resource dependency.

Troubleshooting

The XML or XSLT will not parse

Remove malformed markup, prohibited declarations, and unescaped characters, then validate again.

A placeholder remains visible

Confirm its spelling and field mapping and ensure it was not escaped with a backslash.

The DOCX opens with a repair warning

Inspect OpenXML namespaces, relationships, part paths, content types, and body or section structure.

Related documentation


Documentation source: feradelinc/feradel.render.api, reviewed against repository revision b2c3a710. Verify behavior against the deployed release before publishing exact routes, limits, or version requirements.