<?xml version="1.0"?>
<xsl:stylesheet xmlns="http://www.ivoa.net/xml/ADQL/v0.7.4" 
                xmlns:ad="http://www.ivoa.net/xml/ADQL/v0.7.4" 
                xmlns:q1="urn:nvo-region" 
                xmlns:q2="urn:nvo-coords" 
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                version="1.0">
<xsl:import href="adql2sql_axis.xsl"/>
	<xsl:output method="text"/>
	<xsl:template match="/">
		<xsl:apply-templates select="/*"/>
	</xsl:template>
	<xsl:template match="/*">
		<xsl:text>SELECT </xsl:text>
		<xsl:apply-templates select="Allow"/>
		<xsl:apply-templates select="SelectionList"/>
		<xsl:text> FROM </xsl:text>
		<xsl:apply-templates select="From"/>
		<xsl:apply-templates select="Where"/>
		<xsl:apply-templates select="GroupBy"/>
		<xsl:apply-templates select="Having"/>
		<xsl:apply-templates select="Restrict"/>
		<xsl:apply-templates select="OrderBy"/>
	</xsl:template>
	<!--
        - Restrict Template 
	-->
	<xsl:template match="Restrict">
		<xsl:if test="not(@xsi:nil='true')">
		<xsl:text> LIMIT </xsl:text>
		<xsl:value-of select="@Top"/>
		<xsl:text> </xsl:text>
        </xsl:if>
	</xsl:template>
</xsl:stylesheet>
