cmsplugin-googlesearch / examples / cms-2.0.2 / cmsplugin_googlesearch_example / media / cms / jstree / nested.xsl

<?xml
	version="1.0"
	encoding="utf-8"
	?>
<xsl:stylesheet
	version="1.0"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	>
<xsl:output
	method="html"
	encoding="utf-8"
	omit-xml-declaration="yes"
	standalone="no"
	indent="no"
	media-type="text/html"
	/>

<xsl:param name="theme_name" />
<xsl:param name="theme_path" />

<xsl:template match="/">
	<xsl:call-template name="nodes">
		<xsl:with-param name="node" select="/root" />
		<xsl:with-param name="theme_name" select="$theme_name" />
		<xsl:with-param name="theme_path" select="$theme_path" />
	</xsl:call-template>
</xsl:template>

<xsl:template name="nodes">
	<xsl:param name="node" />
	<xsl:param name="theme_name" />
	<xsl:param name="theme_path" />

	<ul>
	<xsl:if test="$theme_name"><xsl:attribute name="class"><xsl:value-of select="$theme_name" /></xsl:attribute></xsl:if>
	<xsl:for-each select="$node/item">
		<xsl:variable name="children" select="count(./item) &gt; 0" />
		<li>
		<xsl:attribute name="class">
			<xsl:if test="position() = last()"> last </xsl:if>
			<xsl:choose>
				<xsl:when test="@state = 'open'"> open </xsl:when>
				<xsl:when test="$children or @hasChildren"> closed </xsl:when>
				<xsl:otherwise> leaf </xsl:otherwise>
			</xsl:choose>
			<xsl:value-of select="@class" />
		</xsl:attribute>
		<xsl:for-each select="@*">
			<xsl:if test="name() != 'class' and name() != 'state' and name() != 'hasChildren'">
				<xsl:attribute name="{name()}"><xsl:value-of select="." /></xsl:attribute>
			</xsl:if>
		</xsl:for-each>
		<xsl:for-each select="content/name">
			<a href="#">
			<xsl:attribute name="class"><xsl:value-of select="@lang" /> <xsl:value-of select="@class" /></xsl:attribute>
			<xsl:attribute name="style">
				<xsl:value-of select="@style" />
				<xsl:if test="string-length(attribute::icon) > 0">background-image:url(<xsl:if test="not(contains(@icon,'/'))"><xsl:value-of select="$theme_path" /></xsl:if><xsl:value-of select="@icon" />);</xsl:if>
			</xsl:attribute>
			<xsl:for-each select="@*">
				<xsl:if test="name() != 'style' and name() != 'class'">
					<xsl:attribute name="{name()}"><xsl:value-of select="." /></xsl:attribute>
				</xsl:if>
			</xsl:for-each>
			<xsl:value-of select="current()" /></a>
		</xsl:for-each>

		<xsl:if test="$children or @hasChildren">
			<xsl:call-template name="nodes">
				<xsl:with-param name="node" select="current()" />
				<xsl:with-param name="theme_path" select="$theme_path" />
			</xsl:call-template>
		</xsl:if>
		</li>
	</xsl:for-each>
	</ul>
</xsl:template>

</xsl:stylesheet>
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.