Recursive XSLT For Nested XML Nodes In ColdFusion

<!--- Transform the XML and output the result. --->
<cf_xslt xml="#xmlTasks#">
 
	<!--- Document type declaration. --->
	<?xml version="1.0" encoding="ISO-8859-1"?>
 
	<xsl:transform
		version="1.0"
		xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 
 
		<!---
			Start out by matching the root element. This will
			prevent the task node template from matching on
			its own (we only want task nodes to match when we
			explicitly apply templates).
		--->
		<xsl:template match="tasks">
 
			<!--- Begin our initial task list. --->
			<ol>
				<!---
					Now, apply the task template to all
					top-level tasks in the task list.
				--->
				<xsl:apply-templates select="task" />
			</ol>
 
		</xsl:template>
 
 
		<!--- Matches a task node. --->
		<xsl:template match="task">
 
			<!--- Output the task. --->
			<li>
				<span>
					<xsl:value-of select="name" />
				</span>
 
				<!---
					Check to see if there are any sub tasks
					that need their own list.
				--->
				<xsl:if test="task">
 
					<!---
						Start a new sub-task list and then
						RECURSIVELY apply the task template
						to each of the sub-task nodes.
					--->
					<ol>
						<xsl:apply-templates select="task" />
					</ol>
 
				</xsl:if>
			</li>
 
		</xsl:template>
 
 
	</xsl:transform>
 
</cf_xslt>

For Cut-and-Paste