<?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="/">

<html>
<head>
<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>
<style type="text/css" >
body { font-family:Arial,sans-serif }
table { font-size:x-small }
tr { background-color:white }
td { vertical-align:top }
</style>

</head>

<body >

<!-- Get the chart -->
<xsl:for-each select="Catalogue_astro/Charts/Chart">
	     <xsl:choose>
<!-- Manual parameter change point -->
		<xsl:when test="Chart_type[.='Star_number_odd_view']">
			<img style='width=100%' >
				<xsl:attribute name="src">
				<xsl:value-of select="Chart_filename"/>
				</xsl:attribute>
			</img>
		</xsl:when>
	     </xsl:choose>

</xsl:for-each>

<!-- Print the first table by magnitudes -->
<!-- Print the header -->
<!-- Get the table page 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>

<!-- Print the subheader -->
<xsl:for-each select="Catalogue_astro/Charts/Chart">
	     <xsl:choose>
<!-- Manual parameter change point -->
		<xsl:when test="Chart_type[.='Star_number_odd_view']">
		  <h3><xsl:value-of select="Chart_type"/> - by star number</h3>
		</xsl:when>
	     </xsl:choose>
</xsl:for-each>

<!-- 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="Webda_id" data-type='number'/> 
               <xsl:sort select="X_Odd" data-type='number'/>
            </xsl:apply-templates>

</table> 
<!-- End of the table -->

<!-- Print the subheader -->
<xsl:for-each select="Catalogue_astro/Charts/Chart">
	     <xsl:choose>
<!-- Manual parameter change point -->
		<xsl:when test="Chart_type[.='Star_number_odd_view']">
		  <h3><xsl:value-of select="Chart_type"/> - by X-Y coordinate</h3>
		</xsl:when>
	     </xsl:choose>
</xsl:for-each>

<!-- 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="X_Odd" data-type='number'/>
               <xsl:sort select="Y_Odd" data-type='number'/> 
            </xsl:apply-templates>

</table> 
<!-- End of the table -->

<!-- Print the subheader -->
<xsl:for-each select="Catalogue_astro/Charts/Chart">
	     <xsl:choose>
<!-- Manual parameter change point -->
		<xsl:when test="Chart_type[.='Star_number_odd_view']">
		  <h3><xsl:value-of select="Chart_type"/> - by magnitude</h3>
		</xsl:when>
	     </xsl:choose>
</xsl:for-each>

<!-- 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="m_vSt" data-type='number'/>
               <xsl:sort select="X_Odd" data-type='number'/> 
            </xsl:apply-templates>

</table> 
<!-- End of the table -->


<!-- Print the footer notes  -->
<h3>Notes:</h3>
<p> Star 40 is origin of X-Y system</p>
<p> "SP" means "separation-problem", i.e. - the stars are too close to be suitable for use for estimating magnitdues at low magnification (20x).  A low-magnification, the stars may integrate into a single object with a combined magnitude.  Stars with separation problems are left on the chart for reference by higher aperature and magnification telescopes.</p>
<h3>Columns:</h3>
<p> "m_vSt" means the magnitude in the Johnson ubv system - adjusted per Stanton (1999) for the visual system, rounded to one digit </p>
<p> "m_se" means the standard error of m_vSt, when measured with the human eye, rounded to one digit </p>
<p> "U" means whether the star is suitable (useable) for use at low magnification. "Y"=Yes"; "N"="No"</p>
<p> Gray background color in a row means - "U"="N": the star is not suitable for use at low magnification.</p>
<p> "F" and aqua background color means the star has not been field tested.</p>
<p> "X_Dir" means the X coordinate of the X-Y coordinate system in direct view  </p>
<p> "X_Odd" means the X coordinate of the X-Y coordinate system in the odd number of reflections view  </p>
<p> "J_V" means the magnitude through a Johnson V filter </p>
<p> "J_V_se" means the standard error of magnitude through a Johnson V filter</p> 
<p> "J_CI" means the color index B-V in the Johnson ubv system</p> 
<p>Catalogue by:  K. Fisher 3/2004 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 style='font-weight: bold'>
	  <td><xsl:value-of select="Webda_id"/></td>
	  <td ><xsl:value-of select="m_vSt"/></td>
	  <td ><xsl:value-of select="m_vSt_se"/></td>
	  <td ><xsl:value-of select="Useability"/></td>
      	  <td ><xsl:value-of select="Comments"/></td>
	  <td ><xsl:value-of select="X_Direct"/></td>
	  <td ><xsl:value-of select="Y_Direct"/></td>
	  <td ><xsl:value-of select="X_Odd"/></td>
	  <td ><xsl:value-of select="Y_Odd"/></td>
	  <td ><xsl:value-of select="X_Even"/></td>
	  <td ><xsl:value-of select="Y_Even"/></td>
	  <td ><xsl:value-of select="RA_J2000"/></td>
	  <td ><xsl:value-of select="Dec_J2000"/></td>
   	  <td ><xsl:value-of select="Spec"/></td>
   	  <td ><xsl:value-of select="Johnson_V"/></td>
      	  <td ><xsl:value-of select="Johnson_V_se"/></td>
      	  <td ><xsl:value-of select="Johnson_CI"/></td> 
	  <td ><xsl:value-of select="HD_id"/></td>
    	  <td ><xsl:value-of select="Tycho_id"/></td>
        </tr>

</xsl:template>

<!-- Format and return the data table  -->
<xsl:template match="Object_astro">
	
<!--   Format row -->
   	<tr >
<!--   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>

<!-- Format cells in a table row -->
	  <td ><xsl:value-of select="Webda_id"/></td>
	  <td ><xsl:value-of select="m_vSt"/></td>
	  <td ><xsl:value-of select="m_vSt_se"/></td>
	  <td ><xsl:value-of select="Useability"/></td>
      	  <td ><xsl:value-of select="Comments"/></td>
	  <td ><xsl:value-of select="X_Direct"/></td>
	  <td ><xsl:value-of select="Y_Direct"/></td>
	  <td ><xsl:value-of select="X_Odd"/></td>
	  <td ><xsl:value-of select="Y_Odd"/></td>
	  <td ><xsl:value-of select="X_Even"/></td>
	  <td ><xsl:value-of select="Y_Even"/></td>
	  <td ><xsl:value-of select="RA_J2000"/></td>
	  <td ><xsl:value-of select="Dec_J2000"/></td>
   	  <td ><xsl:value-of select="Spec"/></td>
   	  <td ><xsl:value-of select="Johnson_V"/></td>
      	  <td ><xsl:value-of select="Johnson_V_se"/></td>
      	  <td ><xsl:value-of select="Johnson_CI"/></td> 
	  <td ><xsl:value-of select="HD_id"/></td>
    	  <td ><xsl:value-of select="Tycho_id"/></td>
        </tr>

</xsl:template>

</xsl:stylesheet>
