xsl:apply-templates

Selects source nodes for processing.

Format

<xsl:apply-templates [select="pattern"][mode="qname"]>
               
  [<xsl:sort/>]
               
  [<xsl:with-param/>
               
</xsl:apply-templates>
               

            

Description

If you specify the select attribute, specify a pattern that resolves to a set of source nodes. For each source node in this set, the XSLT processor searches for a template that matches the node. When it finds a matching template, it instantiates it and uses the node as the context node. For example:

<xsl:apply-templates select="/bookstore/book">
               

            

When the XSLT processor executes this instruction, it constructs a list of all nodes that match the pattern in the select attribute. For each node in the list, the XSLT processor searches for the template whose match pattern best matches that node.

If you do not specify the select attribute, the XSLT processor uses the default pattern, "node()", which selects all child nodes of the current node.

If you specify the mode attribute, the selected nodes are matched only by templates with a matching mode attribute. The value of mode must be a qualified name or an asterisk ( *). If you specify an asterisk, it means continue the current mode, if any, of the current template.

If you do not specify a mode attribute, the selected nodes are matched only by templates that do not specify a mode attribute.

By default, the new list of source nodes is processed in document order. However, you can use the xsl:sort instruction to specify that the selected nodes are to be processed in a different order. See xsl:sort.

Tip

 

You can create an xsl:apply-templates element automatically using the XSLT mapper.

Example

In the previous example, the XSLT processor searches for a template that matches /bookstore/book. The following template is a match:

<xsl:template match="book">
               
  <tr>
               
   <td><xsl:value-of select="title"/></td>
               
   <td><xsl:value-of select="author"/><td>
               
   <td><xsl:value-of select="price"/><td>
               
  </tr>
               
</xsl:template>
               

            

The XSLT processor instantiates this template for each book element.

XML Schema Editor

Stylus Studio's XML Schema Editor lets you easily develop advanced data models expressed in W3C XML Schema. Its synchronized split-pane interface shows both a visual XML Schema Diagram and the underlying code, and you can edit in either one.

Java IDE

Edit, compile and debug and generate Java code with Stylus Studio's Java Integrated Development Environment (IDE). Supports popular Java XML processing components including Apache Xalan, Apache Axis, Apache Xerces, Saxon and more.

W3C XML Specifications

Learn about the official W3C XML specifications for XML, XSLT, XQuery, XPath, DOM, XML Namespaces, XInclude, XML Base, XPointer, WSDL and more.

EDI Mapping

To transform EDI to XML, whether for X12 or EDIFACT, Stylus Studio provides the design tools and run-time support. EDIFACT, X12 and custom EDI formats can be translated, validated and mapped using the EDI Mapping adapter technology described here.

Stylus Most Wanted

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2007 All Rights Reserved.