<?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:ns1="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="adql2pgsql_axis.xsl"/>

	<!-- 
	- Stylesheet to convert ADQL version 0.7.4 to an SQL String 
        readable by the ADIL database
	- Version 1.0 - Initial Revision
	- Ramon Williamson, National Center for SuperComputing Applications
	- April 1, 2004
	- Based on the schema: http://www.ivoa.net/internal/IVOA/IvoaVOQL/ADQL-0.7.4.xsd
    
    - This sytlesheet imports the adql2pgsql_axis.xsl stylesheet (for 	 PostgreSQL database queries) and overides the 
	 columnReferenceType template to customize the 
      column response to the ADIL database columns (a couple of 
      columns are hidden to users as they are formatted versions of 
      the "official" columns exposed. We want to return results from
      these formatted columns, so the template resets the column
      name returned.
	-->
	<!--
     -  Table Columns (columnReferenceType)
     -->
	<xsl:template match="*[@xsi:type='ns1:columnReferenceType'] | 
        *[@xsi:type='columnReferenceType']">
		<xsl:if test="not(@xsi:nil='true')">
			<xsl:value-of select="@Table"/>
			<xsl:text>.</xsl:text>
            	<xsl:choose>
            		<xsl:when test="@Name= 'author'">
					<xsl:text>s_author</xsl:text>
				</xsl:when>
				<xsl:when test="@Name= 'title'">
					<xsl:text>s_title</xsl:text>
				</xsl:when>
				<xsl:when test="@Name= 'reference'">
					<xsl:text>s_reference</xsl:text>
				</xsl:when>
				<xsl:when test="@Name= 'objname'">
					<xsl:text>s_objname</xsl:text>
				</xsl:when>
				<xsl:when test="@Name= 'objtype'">
					<xsl:text>s_objtype</xsl:text>
				</xsl:when>
				<xsl:when test="@Name= 'species'">
					<xsl:text>s_species</xsl:text>
				</xsl:when>
				<xsl:when test="@Name= 'telescope'">
					<xsl:text>s_telescope</xsl:text>
				</xsl:when>
				<xsl:otherwise>
					<xsl:value-of select="@Name"/>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:if>
	</xsl:template>
</xsl:stylesheet>
