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.
About this task
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:
Procedure
- Open your XSL file in the XSL
editor.
- Click the Snippets tab,
open the XSL drawer,
and then double-click xsl:apply-templates element.
- 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.
- Click xsl:apply-templates in
the Parameter
list.
- 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.
- 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
- (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:
- Select the parameter you just created.
- In the Name field,
type the name of parameter.
- 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.
- Click Finish and
the <xsl:apply-templates>
element will be inserted into the XSL file.