XML/XSLT stylesheet/subsequence
A list of sequence
File: Data.xml
File: Transform.xslt
<?xml version="1.0"?>
<xsl:stylesheet version="2.0"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>
<xsl:template match="/">
<xsl:variable name="cities" as="xs:string*">
<xsl:sequence select="addressbook/address/city"/>
<xsl:sequence select="("A", "B", "C")"/>
<xsl:sequence select="("D", "E", "F")"/>
</xsl:variable>
<xsl:text>Our customers live in these cities:

</xsl:text>
<xsl:value-of select="$cities" separator="
"/>
</xsl:template>
</xsl:stylesheet>
Output:
Our customers live in these cities:
A
B
C
D
E
F
Define sequence
File: Data.xml
File: Transform.xslt
<?xml version="1.0"?>
<xsl:stylesheet version="2.0"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>
<xsl:template match="/">
<xsl:variable name="months" as="xs:string*">
<xsl:sequence
select="("January", "February", "March", "April",
"May", "June", "July", "August",
"September", "October", "November",
"December")"/>
</xsl:variable>
<xsl:text>Here are the months of the year:

</xsl:text>
<xsl:value-of select="$months" separator="
"/>
</xsl:template>
</xsl:stylesheet>
Output:
Here are the months of the year:
January
February
March
April
May
June
July
August
September
October
November
December
subsequence() function
File: Data.xml
<?xml version="1.0" encoding="utf-8"?>
<favorite-books>
<booklist>
<book isbn="1111111111"
favorite="f1">XSLT</book>
</booklist>
</favorite-books>
File: Transform.xslt
<?xml version="1.0"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>
<xsl:variable name="Dougs-favorites" as="node()*">
<xsl:sequence
select="/favorite-books/booklist
/book[contains(@favorite, "Doug")]"/>
</xsl:variable>
<xsl:template match="/">
<xsl:text>A test of the node-after (>>) operator:</xsl:text>
<xsl:text>

 Comparing nodes from </xsl:text>
<xsl:text>the sequence:
</xsl:text>
<xsl:value-of
select="if (subsequence($Dougs-favorites, 1, 1) >>
subsequence($Dougs-favorites, 2, 1))
then " node1 >> node2 = true
"
else " node1 >> node2 = false
""/>
<xsl:value-of
select="if (subsequence($Dougs-favorites, 2, 1) >>
subsequence($Dougs-favorites, 1, 1))
then " node2 >> node1 = true
"
else " node2 >> node1 = false
""/>
<xsl:value-of
select="if (subsequence($Dougs-favorites, 1, 1) >>
subsequence($Dougs-favorites, 1, 1))
then " node1 >> node1 = true
"
else " node1 >> node1 = false
""/>
</xsl:template>
</xsl:stylesheet>
Output:
A test of the node-after (>>) operator:
Comparing nodes from the sequence:
node1 >> node2 = false
node2 >> node1 = false
node1 >> node1 = false