Skip to content

Apply Template

Apply Template widget renders a form template from process definition.

Rules and Validation

The <ApplyTemplate> widget supports validation and formatting rules, affecting content visibility and data validation. These rules also apply to elements within the template itself.

Parameters

Templates support parameters passed from the parent form. These parameters are accessed as variables (with a $ prefix) within XPath expressions and scripts. Variable names must adhere to XML naming conventions, and values must be static.

XML Fields

  • Name selects the form template defined in the process definition.
  • XPath establishes the data context passed to the template. The widgets inside the template resolve their relative paths from this context.
  • Parameters contains named values made available to the template. Each child element name is the parameter name and its content is the value passed to the template.
  • Rules contains rules that apply to the template instance as a whole. Widgets inside the template retain their own rules as well.

ApplyTemplate does not duplicate the template definition in the form XML. It refers to a named definition and supplies the context and optional parameter values for that instance.

Example Template Usage

1
2
3
4
<ApplyTemplate Name="MyTemplate" XPath="MyContainer">
    <Rules />
    <Parameters />
</ApplyTemplate>

Example with Parameters:

1
2
3
4
5
6
<ApplyTemplate Name="MyTemplate" XPath="MyContainer">
    <Rules />
    <Parameters>
        <MyVariable Type="System.String"><![CDATA[10]]></MyVariable>
    </Parameters>
</ApplyTemplate>

In this example, MyVariable is passed to the template with a value of "10". It can then be used within the template's XPath expressions (e.g., Total > $MyVariable).