<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
<!--   This namespace reference is required, whether off-line or online to trigger MS-IE xsl processor -->

<!-- XML style sheet for sorted stellar catalogue display -->

<!-- Force output as html document; not xml document; default is "xml" -->
<xsl:output method="html" indent="yes" />

<!-- Begin transform XML to HTML page header and table data -->
<xsl:template match="/">

<!--     Start the HTML page header -->
<html>
<head>

<!-- Content rating -->
<link rel="meta" href="http://members.csolutions.net/fisherka/astronote/Clarkxref/labels.xml" type="application/rdf+xml" title="ICRA labels" />

<!--     Set the HTML page header -->
<title>
<!-- Set the window title -->
<!--     Compare this title string get method to the template method used for the page header -->
<xsl:for-each select="Catalogue_astro">
<xsl:value-of select="Catalogue_Name"/>
</xsl:for-each>
</title>

<!--     Set the HTML CSS styles -->
<style type="text/css">
table
{ 
font-family: sans-serif;  
}
thead 
{
vertical-align: top;
text-align: left;
font-family: sans-serif; 
font-weight: bold;
}
th
{
vertical-align: top;
text-align: left;
font-family: sans-serif; 
font-weight: bold;
}
td 
{
vertical-align: top;
overflow: scroll; 
}
p
{
font-family: sans-serif; 
}
p.small
{
font-family: sans-serif; 
font-size: small;
}
body
{
font-family: sans-serif; 
}

</style>

</head>


<!--     Start the HTML document body -->
<body >

<!-- Print the first table by magnitudes -->
<!-- Print the header -->
<!-- Get the page title header -->
<!--     Compare this title string get method to the data-driven for-each method used for the HTML title tag -->
            <xsl:apply-templates select="Catalogue_astro">
               <xsl:sort select="Catalogue_Name"/>
            </xsl:apply-templates>

<!-- Start the table -->
<table >

<!-- Get the table header row -->
            <xsl:apply-templates select="Catalogue_astro/Catalogue_fields">
               <xsl:sort select="Webda_id"/>
            </xsl:apply-templates>

<!-- Get the data table body -->
            <xsl:apply-templates select="Catalogue_astro/Catalogue_objects/Object_astro">
<!-- Sort the data table.  Sort order is set here.  -->
<!--      Note use of data-type tag for numeric fields.  -->
<!-- Manual paramter change point -->
	       <xsl:sort select="PGC_Name" order='descending' data-type='text'/> 
               <xsl:sort select="Cat_id" order='ascending' data-type='text'/>

<!--               
Catalogue Id
     <xsl:sort select="Cat_id" order='ascending' data-type='text'/>

Clark ids descending
	       <xsl:sort select="ClarkID" order='descending' data-type='text'/> 
               <xsl:sort select="NGC_Name" order='ascending' data-type='text'/>

Galactic coords
               <xsl:sort select="G2000Pos" order='ascending' data-type='text'/>
J2000 coords 
               <xsl:sort select="GJ000Pos" order='ascending' data-type='text'/>

Store sort statements -->

            </xsl:apply-templates>

</table> 
<!-- End of the table -->

<!-- Print the footer notes  -->

<p> Prepared by:  K. Fisher 3/2006 fisherka@csolutions.net</p>

</body>

</html>

<!-- End transform XML to HTML page header and table data -->
</xsl:template>

<!-- Begin templates to format XML data -->

<!-- Format and return the page header  -->
<xsl:template match="Catalogue_astro">
	<h3><xsl:value-of select="Catalogue_Name"/></h3>
</xsl:template>

<!-- Format and return the table header  -->
<xsl:template match="Catalogue_fields">
        <tr >
	  <th ><xsl:value-of select="Cat_id"/></th>
	  <th ><xsl:value-of select="Con"/></th>
      	  <th ><xsl:value-of select="J2000Pos"/></th>
	  <th ><xsl:value-of select="V_mag"/></th>
	  <th ><xsl:value-of select="L_opacity"/></th>
	  <th ><xsl:value-of select="Type_Simbad"/></th>
	  <th ><xsl:value-of select="ClarkID"/></th>
	  <th ><xsl:value-of select="M_Name"/></th>
	  <th ><xsl:value-of select="CaldwellName"/></th>
	  <th ><xsl:value-of select="Herschel400"/></th>
	  <th ><xsl:value-of select="Arp_Id"/></th>
   	  <th ><xsl:value-of select="Barnard_Name"/></th>
   	  <th ><xsl:value-of select="LDN"/></th>
      	  <th ><xsl:value-of select="NGC_Name"/></th>
      	  <th ><xsl:value-of select="PGC_Name"/></th> 
	  <th ><xsl:value-of select="Common_names"/></th>
    	  <th ><xsl:value-of select="G2000Pos"/></th>
    	  <th ><xsl:value-of select="Size_majoraxis_arcmin"/></th>
    	  <th ><xsl:value-of select="Size_minoraxis_arcmin"/></th>
    	  <th ><xsl:value-of select="Distance_kparsecs"/></th>
    	  <th ><xsl:value-of select="Comments"/></th>
    	  <th ><xsl:value-of select="PositionSubCategory"/></th>
        </tr>

</xsl:template>

<!-- Format and return the data table  -->
<xsl:template match="Object_astro">

	
<!--   Format row -->
   	<tr >

<!--   Is deprecated code retained for future reference - With conditional background colors -->
<!--   With conditional background colors  -->
	<xsl:attribute name="STYLE">background-color:
	     <xsl:choose>
		<xsl:when test="Useability[.='	N	']">silver</xsl:when>
		<xsl:when test="Useability[.='	F	']">aqua</xsl:when>
		<xsl:otherwise>white</xsl:otherwise>
	     </xsl:choose>
	</xsl:attribute>
<!--   Is deprecated code retained for future reference - With conditional background colors -->


<!-- Format cells in a table row -->
	  <td ><xsl:value-of select="Cat_id"/></td>
	  <td ><xsl:value-of select="Con"/></td>
      	  <td ><xsl:value-of select="J2000Pos"/></td>
	  <td ><xsl:value-of select="V_mag"/></td>
	  <td ><xsl:value-of select="L_opacity"/></td>
	  <td ><xsl:value-of select="Type_Simbad"/></td>
	  <td ><xsl:value-of select="ClarkID"/></td>
	  <td ><xsl:value-of select="M_Name"/></td>
	  <td ><xsl:value-of select="CaldwellName"/></td>
	  <td ><xsl:value-of select="Herschel400"/></td>
	  <td ><xsl:value-of select="Arp_Id"/></td>
   	  <td ><xsl:value-of select="Barnard_Name"/></td>
   	  <td ><xsl:value-of select="LDN"/></td>
      	  <td ><xsl:value-of select="NGC_Name"/></td>
      	  <td ><xsl:value-of select="PGC_Name"/></td> 
	  <td ><xsl:value-of select="Common_names"/></td>
    	  <td ><xsl:value-of select="G2000Pos"/></td>
    	  <td ><xsl:value-of select="Size_majoraxis_arcmin"/></td>
    	  <td ><xsl:value-of select="Size_minoraxis_arcmin"/></td>
    	  <td ><xsl:value-of select="Distance_kparsecs"/></td>
    	  <td ><xsl:value-of select="Comments"/></td>
    	  <td ><xsl:value-of select="PositionSubCategory"/></td>
        </tr>

</xsl:template>

</xsl:stylesheet>
