Looping and Sorting - Exercise

Contact Us or call 1-877-932-8228
Looping and Sorting - Exercise

Looping and Sorting

Duration: 5 to 10 minutes.

In this exercise, you will modify the XSLT you created in the last exercise so that the results are sorted by FirstName.

  1. Open FlowControl/Exercises/ForEachSort.xsl for editing.
  2. Modify the code so that the results will be sorted by FirstName.
  3. To test your solution, transform FlowControl/Exercises/BusinessLetterSort.xml against FlowControl/Exercises/ForEachSort.xsl.


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
	<xsl:output method="xml" indent="yes"/>
	<xsl:template match="/">
		<xsl:for-each select="//Name">
			<xsl:sort select="FirstName"/>
					<Title><xsl:value-of select="@Title"/></Title>
					<FName><xsl:value-of select="FirstName"/></FName>
					<LName><xsl:value-of select="LastName"/></LName>