Simple XML/XSL tree navigation

Here is a simple XML/XSL tree navigation. I have made almost all XML/XSL navigations based on this XSL.
XSL transforms XML tree to XHTML list view.


XML source


<?xml version="1.0"?>
<tree>

<folder type="folder">
<name>item 01</name>
</folder>
<folder type="folder">
<name>item 02</name>
</folder>
<folder type="folder">
<name>item 01</name>
<folder type="folder">
<name>item 01 01</name>
<folder type="folder">
<name>item 01 01 01</name>
<folder type="folder">
<name>item 01 01 01 01</name>
<folder type="folder">
<name>item 01 01 01 01 01</name>
</folder>
</folder>
</folder>
</folder>
</folder>
<folder type="folder" value="04 folder">
<name>item 03</name>
</folder>


</tree>

XSL Source


<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method = "xml" />
<xsl:template match="/">
<html>
<body><xsl:apply-templates select="tree/folder" /></body>
</html>
</xsl:template>
<xsl:template match="folder">
<xsl:choose>
<xsl:when test="boolean(folder)">
<li><xsl:value-of select="name" /></li>
</xsl:when>
<xsl:otherwise>
<li><xsl:value-of select="name"/></li>
</xsl:otherwise>
</xsl:choose>
<ul>
<xsl:if test="."><xsl:apply-templates select="folder" /></xsl:if>
</ul>
</xsl:template>
</xsl:stylesheet>