<?xml version="1.0" encoding="UTF-8"?><!-- DWXMLSource="../../../submitted/assign1.xml" -->
<!-- http://153.18.145.30/~raupmart/assign1.htm -->
<!-- Raup, Martha -->
<!-- COIN 78b Section 01W Fall 2010 -->
<xsl:stylesheet 
	version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:v="urn:schemas-microsoft-com:vml"     
    xmlns:svg="http://www.w3.org/2000/svg version='1.1'" >
 
 <xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
  
  <xsl:template match="/"> 
   
  		<xsl:apply-templates select="PERIODIC_TABLE" />
  </xsl:template>
  
  <xsl:template match="PERIODIC_TABLE">
   	 <html>
     	<head>
        	<title>Table of Elements</title>
            <style>v\: * { behavior:url(#default#VML);display:inline-block }</style>
        </head>
        
 	 	<body>
          <h1>Table of Elements</h1>
            <table border="1px">    
              <tr>
                  <th>Atomic Number</th>
                  <th>Symbol</th>
                  <th>Name</th>
                  <th>Atomic Weight</th><th>Melting Point<br />(<xsl:value-of select="//MELTING_POINT/@UNITS" />)</th>
                 <th>Boiling Point<br />(<xsl:value-of select="//BOILING_POINT/@UNITS" />)</th>
                  <th>Atomic Radius<br />(<xsl:value-of select="//ATOMIC_RADIUS/@UNITS" />)</th>
                  <th>State<br />(@ 300K)</th>
              </tr>
              
          	<xsl:apply-templates select="ATOM" />
          
               <tr> <td colspan="8">Total Number of Elements: <xsl:value-of select="count(//ATOMIC_NUMBER)" /></td> </tr>
                <!-- Code Assistance from: http://zvon.org/xxl/XSLTreference/OutputOverview/function_sum_frame.html -->    
           </table>
        </body>
 	 </html>
  </xsl:template>
  
  <xsl:template match="ATOM">
       
  <!-- Create a variable at top level to store the height & width of radius, where h & w = 10 x round(radius) -->
  <!-- I tried that (just under <xsl:template match="/" />), but this gave error message: shape was not defined. -->
  <!-- In this location, it works! -->  
    <xsl:variable name="state" select="round(ATOMIC_RADIUS)"/>
    <xsl:variable name="shape" select="$state * 10"/>    
    <xsl:variable name="BP" select="//BOILING_POINT" />    	
    <xsl:variable name="MP" select="//MELTING_POINT" />    	
    <xsl:variable name="SRT" select="298" /> 
	<xsl:variable name="gas"></xsl:variable> <!-- $BP &lt; $SRT and $MP &lt; $SRT -->
    <xsl:variable name="solid"></xsl:variable> <!-- $BP &gt; $SRT and $MP &gt; $SRT -->
    <xsl:variable name="liquid"></xsl:variable> <!-- $MP &lt; $SRT and $BP &gt; $SRT -->

     
 <tr> <xsl:for-each select="."><xsl:sort select="SYMBOL" /></xsl:for-each>
<!--   Code assistance from: http://www.java2s.com/Tutorial/XML/0100__XSLT-stylesheet/whentestpositionmod40.htm -->
          <xsl:attribute name="style">
              <xsl:choose>
                  <xsl:when test="position() mod 2 = 0">
                      <xsl:text>background: yellow;</xsl:text>
                  </xsl:when>
                  <xsl:otherwise>
                      <xsl:text>background: green;</xsl:text>
                      <xsl:text>color: white;</xsl:text>
                  </xsl:otherwise>
              </xsl:choose>              
           </xsl:attribute>
                    
      <td><xsl:value-of select="ATOMIC_NUMBER" /></td>
      <td><xsl:value-of select="SYMBOL" /></td>        
      <td><xsl:value-of select="NAME" /></td>
      <td><xsl:value-of select="ATOMIC_WEIGHT" /></td>
      <td><xsl:value-of select="MELTING_POINT" /></td>
      <td><xsl:value-of select="BOILING_POINT" /></td>
      <td><xsl:value-of select="ATOMIC_RADIUS" /></td>
           

      <td>
      <!--  Inspiration from: http://documenta.rudolphina.org/c-cond-html.xsl
      		 Copyright 2008 Manfred Staudinger, Vienna, Austria - ADAPTED by Martha

<xsl:variable name="non-IE-text" select="'ABCDFGHJKLMNOPQRSTUVWXYZabcdfhijkmnopqrsuvwxyz'"/>
<xsl:variable name="vendor" select="system-property('xsl:vendor')"/>
<xsl:variable name="node-set" select="function-available('exsl:node-set')"/>
−
<xsl:variable name="browser">
−
<xsl:choose>
−
<xsl:when test="$vendor='Microsoft' and $ASV">
<xsl:value-of select="'IE, SVG'"/>
</xsl:when>
−
<xsl:when test="$vendor='Microsoft'">
<xsl:value-of select="'IE, noSVG'"/>
</xsl:when>
−
<xsl:when test="$vendor='Transformiix' and not(element-available('xsl:fallback'))">
<xsl:value-of select="'Firefox 1, FF 1, Firefox, Gecko 1.7, Mozilla 1.7, Camino 0.8, Camino, Netscape, noSVG'"/>
</xsl:when>
−
<xsl:when test="$vendor='Transformiix' and not($node-set)">
<xsl:value-of select="'Firefox 2, FF 2, Firefox, Gecko 1.8, SeaMonkey 1, SeaMonkey, Camino 1, Camino, Epiphany 2.14, Epiphany 2.20, Epiphany, Flock, K-Meleon, Kazehakase, Netscape, Navigator, SVG'"/>
</xsl:when>
−
<xsl:when test="$vendor='Transformiix' and $node-set">
<xsl:value-of select="'Firefox 3, FF 3, Firefox, Gecko 1.9, SeaMonkey 2, SeaMonkey, Camino 2, Camino, Epiphany 2.22, Epiphany, Minefield, SVG'"/>
</xsl:when>
−
<xsl:when test="$vendor='libxslt' and not($node-set)">
<xsl:value-of select="'Safari 1, Safari 2, Safari, noSVG'"/>
</xsl:when>
−
<xsl:when test="$vendor='libxslt' and $node-set">
<xsl:value-of select="'Safari 3, Safari, SVG'"/>
</xsl:when>
−
<xsl:when test="$vendor='Opera' and not(function-available('document'))">
<xsl:value-of select="'Opera 9, Opera, SVG'"/>
</xsl:when>
−
<xsl:when test="$vendor='Opera' and function-available('document')">
<xsl:value-of select="'Opera 9.50, Opera, SVG'"/>

</xsl:when>
−
<xsl:when test="$vendor='Apache Software Foundation'">
<xsl:value-of select="'X-Smiles, SVG'"/>
</xsl:when>
−
<xsl:otherwise>
<xsl:value-of select="'unknown'"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
      -->    
          <xsl:variable name="vendor" select="system-property('xsl:vendor')"/>
      <xsl:choose>
      	<xsl:when test="$vendor='Microsoft'">
      
        	
           <v:oval style="width:{$shape}; height:{$shape};"  /> 
          
            	 <xsl:if test="$BP &lt; $SRT and $MP &lt; $SRT">
                	<xsl:attribute name="filled">
                    	<xsl:text>false</xsl:text>  
                    </xsl:attribute>
            	</xsl:if> 
                <xsl:if test="$BP &gt; $SRT and $MP &gt; $SRT"> 
					<xsl:attribute name="fillcolor">           	
                		<xsl:text>blue</xsl:text>
                    </xsl:attribute>            
           		</xsl:if>            
            	<xsl:if test="$MP &lt; $SRT and $BP &gt; $SRT">
                	<xsl:attribute name="fillcolor">            	
                		<xsl:text>white</xsl:text>
                    </xsl:attribute>               
            	</xsl:if> 
        </xsl:when>
        <xsl:otherwise>
        	<svg xmlns="http://www.w3.org/2000/svg" height="$state">
            	<circle cx="$state" cy="$state" r="$shape" id="circ" style="fill:red;"/>
          	</svg></xsl:otherwise> 
      </xsl:choose>

  	            	
                     	                
		</td>    
	</tr>  
  </xsl:template>
  <xsl:template match="text()">
      <xsl:value-of select="." />
  </xsl:template>

</xsl:stylesheet>	