Name
[2.0] <xsl:sequence>
Creates a sequence of nodes and/or atomic values.
Category
Instruction.
Required Attribute
select
An XPath expression that determines the content of the sequence.
Optional Attributes
None.
Content
Zero or more <xsl:fallback>
elements. The <xsl:fallback>
element specifies
processing that should take place in the case of an element that the
XSLT processor doesn’t support. They are most commonly written for
XSLT 1.0 processors operating in forwards-compatible mode.
Appears in
A template.
Defined in
XSLT section 11.10, “Constructing Sequences.”
Example
We’ll use a simple example here that creates a sequence inside
an <xsl:variable>
. Here’s the
stylesheet:
<?xml version="1.0" encoding="utf-8"?> <!-- sequence.xsl --> <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xsl:output method="text"/> <xsl:template match="/"> <xsl:variable name="sales" as="xs:integer*"> <xsl:for-each select="/report/brand/units"> <xsl:if test=". > 10000"> <xsl:sequence select="."/> </xsl:if> </xsl:for-each> </xsl:variable> <xsl:value-of select="/report/title"/> <xsl:text>

Sales figures: </xsl:text> <xsl:value-of select="$sales" separator=", "/> <xsl:text>

Sequence total: 	</xsl:text> <xsl:value-of select="format-number(sum($sales), '$#,###.00')"/> <xsl:text>
Sequence average:	</xsl:text> <xsl:value-of select="format-number(avg($sales), '$#,###.00')"/> </xsl:template> </xsl:stylesheet>
Inside the
Get XSLT, 2nd 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.