menu.xslt example

<!--
                 FOR DEMO USE ONLY
       Copyright by Artem Saveliev artem@savelev.com
-->

<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:param name="pagename"></xsl:param>
<xsl:param name="pageid"></xsl:param>

<xsl:template match="/item">
	<script>
		var path = "0<xsl:apply-templates select="item[.//item[@Target=$pagename or @id=$pageid]  or @Target=$pagename or @id=$pageid]" mode="path"/>";
		var a = <xsl:apply-templates select="/item" mode="array"/>;
	</script>

	<table onmouseout="timeit()" border="0" cellspacing="0" cellpadding="0" width="100%">

	<tr><td id="line0" bgcolor="#0048E1" height="19px" style="padding-left:15px;"></td></tr>

	<tr><td bgcolor="#999999"><img src="images/t.gif" height="1" /></td></tr>

	<tr><td id="line1" bgcolor="#1470FA" height="19px" style="padding-left:60px;"></td></tr>

	<tr><td bgcolor="#999999"><img src="images/t.gif" height="1" /></td></tr>

	<tr><td id="line2" bgcolor="#478CF2" height="19px" style="padding-left:90px;"></td></tr>

	</table>
</xsl:template>

<xsl:template match="item" mode="path">-<xsl:value-of select="count(preceding-sibling::*)"/>

		<xsl:apply-templates select="item[.//item[@Target=$pagename or @id=$pageid] or @Target=$pagename or @id=$pageid]" mode="path"/>
</xsl:template>

<xsl:template match="item" mode="array">new Array(
		<xsl:if test="@Text">

			"<xsl:value-of select="@Text"/>",
			"forms/<xsl:value-of select="@Target"/>",
			"<xsl:value-of select="@ToolTip"/>"
			<xsl:if test="item">,</xsl:if>

		</xsl:if>
		
		<xsl:if test="item">new Array(</xsl:if>

		<xsl:apply-templates select="item" mode="array"/>
		<xsl:if test="item">)</xsl:if>)
		
		<xsl:if test="count(following-sibling::*)">,</xsl:if>

</xsl:template>

</xsl:stylesheet>