xsl:apply-templates

<xsl:apply-templates>
<xsl:apply-templates
select=”expression”
mode=”qname” >
</xsl:apply-templates>
The xsl:apply-templates element defines a set of nodes to be processed, or by default selects all child nodes of the current node being processed, and finds a matching template rule to apply to each node in the set.
Since each node in the node set is treated individually, it is possible for each node to have a different template applied to it. Note that a template rule is not actually returned, but rather, it manifests itself by how the node is displayed in the output.
There are only two possible procedures by which a template rule can be chosen for a node. If the node matches the pattern defined by the match attribute of an xsl:template element, then that template will be applied.
If more that one such match occurs, then the template with the highest priority will be applied. Or if the priorities are the same, the last template encountered with that priority will be applied. If there are no templates, or a match cannot be found, then the XSLT processor will apply a built-in template rule.
The xsl:apply-templates element can only contain the xsl:sort or xsl:with-param elements. By default the nodes will be assigned templates in the order that they occur. However, if there are one or more xsl:sort instructions, then the nodes will be sorted before the templates are assigned.
The actual assignment of a template to a specific individual node is not dependent on the sorting order. The xsl:with-param element defines parameters that will be applied to the template rules.
This is not a self-closing element. The separate closing element is mandatory.
mode=”qname”
The optional mode attribute allows the same nodes to be processed more than once. Each time the nodes are processed, they can be displayed in a different manner. A qname is a qualified name that is composed of an optional namespace prefix, a colon which is only present if there is a prefix, and a mandatory XML name (for example, xsl:zipcode or zipcode).
If an xsl:apply-templates element has a mode attribute, then it can only apply template rules fromxsl:template elements that also have a mode attribute.
select=”expression”
The optional select attribute is set to an expression that returns a node set. This can simply be a string that is the name of a node set.
The nodes in the node set are processed in the order that they occur (which is called document order). The default for omitting this attribute is to select all of the child nodes of the current node being processed.