Adding <xsl:apply-templates> elements to XSL files

The <xsl: apply-templates> element is used from within a template to call other templates. You can use the select attribute to determine what context node is used when this element is evaluated, and the mode attribute to call specific templates using their mode value.

The following instructions were written for the Resource perspective, but they will also work in many other perspectives.

Follow these steps to add an <xsl:apply-templates> element to your XSL file. As it is being defined, the <xsl:apply-templates> element will be displayed in a read-only field:

  1. Open your XSL file in the XSL editor.
  2. Click the Snippets tab, open the XSL drawer, and then double-click xsl:apply-templates element.
  3. The match templates in your style sheet will be listed. You can use the value of your match pattern as the value of your select expression if you want to specifically invoke the matched template, or you can use the match pattern as a guide for refining your select expression.
  4. Click xsl:apply-templates in the Parameter list.
    1. The Mode attribute is optional. It is used to provide modularity so that you can group templates together sharing the same value. The only templates that will be called by xsl:apply-templates are those that have the same mode value as the one you enter in this field.
    2. The Select attribute is optional. When it is absent, all children of the current node are selected. Otherwise, the nodes matched are determined by the value of the XPath expression in the Select field. To create a value for the Select field you can:
      • Type the XPath expression in this field or
      • Click XPath if you want to use the XPath Expression wizard to create the XPath expression or
      • Select your match pattern in the Select a match pattern field
  5. (Optional) Click the Add Parameter button to add an xsl:with-param parameter. Parameters are passed to templates using the xsl:with-param element. If you select a match template that already has parameters defined, they will automatically be added to the Parameter list:
    1. Select the parameter you just created.
    2. In the Name field, type the name of parameter.
    3. In the Select field, type the default value of the parameter.  Click XPath if you want to use the XPath Expression wizard to create the default value.
  6. Click Finish and the <xsl:apply-templates> element will be inserted into the XSL file.
Related concepts
XSL editor

Feedback