YouTip LogoYouTip

El Apply Templates

XSLT Element

XSLT Element

--

XSLT Tutorial

XSLT Tutorial XSL Language XSLT Introduction XSLT Browsers XSLT Transformation <a href="#" title="XSLT Element">XSLT Element <a href="#" title="XSLT Element">XSLT Element <a href="#" title="XSLT Element">XSLT Element <a href="#" title="XSLT Element">XSLT Element <a href="#" title="XSLT Element">XSLT Element <a href="#" title="XSLT Element">XSLT Element <a href="#" title="XSLT Element">XSLT Element XSLT on Client Side XSLT on Server Side XSLT - Edit XML XML Editors XSLT Summary XSLT Examples XSLT Elements XSLT Functions XSLT Transformation Tools XSLT Examples XSLT Functions

In-depth Exploration

Programming

Web Design and Development

Web Services

Software

Web Service

Scripting Languages

Search

Computer Science

Programming Languages

Development Tools

XSLT Element

Image 3: XSLT Element Reference Manual Complete XSLT Element Reference Manual

Definition and Usage

The element applies templates to the current element or its child nodes.

If we add a select attribute to the element, it will only process the child elements that match the value of this attribute. We can use the select attribute to specify the order of the child nodes to be processed.

Syntax

<xsl:apply-templates select="expression" mode="name">
    <!-- Content:(xsl:sort|xsl:with-param)* -->
</xsl:apply-templates>

Attributes

Attribute Value Description
select expression Optional. Specifies which nodes to process. An asterisk selects the entire node set. If omitted, all child nodes of the current node are selected.
mode name Optional. If there are multiple processing methods defined for the same element, mode can be used to distinguish them.

Example 1

Surround each title element in the document with an h1 element:

<?xml version="1.0" encoding="ISO-8859-1"?>

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="title">
  <h1><xsl:apply-templates/></h1>
</xsl:template>

</xsl:stylesheet>

Example 2

Surround all title elements that are children of message in the document with an h1 element:

<?xml version="1.0" encoding="ISO-8859-1"?>

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="message">
  <h1><xsl:apply-templates select="title"/></h1>
</xsl:template>

</xsl:stylesheet>

Example 3

Surround all child nodes of message where the mode attribute is set to "big" in the document with an h1 element:

<?xml version="1.0" encoding="ISO-8859-1"?>

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="message">
  <h1><xsl:apply-templates select="*" mode="big"/></h1>
</xsl:template>

</xsl:stylesheet>

Image 4: XSLT Element Reference Manual Complete XSLT Element Reference Manual

XSLT Examples XSLT Functions
← El AttributeEl Apply Imports β†’