<?xml version="1.0" encoding="ISO-8859-1" ?> 
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">
	<xsl:apply-templates select="./menu/pasta" />
</xsl:template>


<xsl:template match="menu/pasta" priority="100">
	<xsl:apply-templates select="./pasta" />
</xsl:template>

<xsl:template match="menu/pasta/pasta" priority="200">
 <xsl:if test="count(./*) &gt; 0">
	HM_Array<xsl:value-of select="@sn"/> = [
	[],
	<xsl:apply-templates select="./pasta/*" />
	]
  </xsl:if>
</xsl:template>


<xsl:template match="menu/pag" priority="100"></xsl:template>


<xsl:template match="pasta" priority="10">
 <xsl:variable name="aux"><xsl:choose><xsl:when test="count(./*) &gt; 0">1</xsl:when><xsl:otherwise>0</xsl:otherwise></xsl:choose></xsl:variable>
	["<xsl:value-of select="text()" />","_X_URL_X_?id_pasta=<xsl:value-of select="@id_pasta" />",1,0,<xsl:value-of select="$aux"/>]
 <xsl:if test="not(position()=last())">,</xsl:if>
</xsl:template>


<xsl:template match="pag" priority="10">
	["<xsl:value-of select="text()" />","_X_URL_X_?id_pasta=<xsl:value-of select="@id_pasta" />&amp;id_pagina=<xsl:value-of select="@id_pagina" />",1,0,0]
 <xsl:if test="not(position()=last())">,</xsl:if>
</xsl:template>


</xsl:stylesheet>

