Create dynamic reusable XSLT OpenXML fragments safely.
Overview
Create dynamic reusable XSLT OpenXML fragments safely. Author templates against a documented data contract and a known-good base package. Keep source files, sample data, and expected output together.
Key points
- Native content must be a well-formed stylesheet or supported fragment.
- A stylesheet fragment requires xsl:template match=/.
- Top-level variables, parameters, and named templates are extracted as declarations.
- Friendly placeholders are converted before Saxon validation.
- Native authoring requires the configured elevated permission.
Example
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">
<xsl:template match="/">
<w:p>
<w:r>
<w:t>Case [[matter.caseNumber]]</w:t>
</w:r>
</w:p>
</xsl:template>
</xsl:stylesheet>
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
- Prepare sample XML that includes optional and repeated data.
- Author the smallest valid transform or fragment.
- Validate placeholders, XPath, XML, XSLT, and OpenXML structure.
- 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
- XSLT Security Restrictions
- WordprocessingML Fragment Authoring
- Use Images, Fonts, and Other Template Resources
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.