Name

xsl:for-each

Synopsis

<xsl:for-each   select = "node-set-expression"> 
  <! --  (xsl:sort*, template)  -- >
</xsl:for-each>

The xsl:for-each instruction iterates over the nodes identified by its select attribute and applies templates to each one.

Attribute

select, required

An XPath node-set expression identifying which nodes to iterate over.

Contents

Normally, the selected nodes are processed in the order in which they appear in the document. However, nodes can be sorted using xsl:sort child elements. The first such element is the primary sort key, the second is the secondary sort key, and so on.

The xsl:for-each element must also contain a template that is instantiated once for each member of the node-set returned by the node-set expression in the select attribute.

Get XML in a Nutshell, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.