<?xml version='1.0' encoding="gb2312"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="utf-8" />
<xsl:template match="root">
<html>
<head>
<title><xsl:value-of select="param[@id='HTMLTITLE']" disable-output-escaping="yes" /></title>
<xsl:apply-templates select="reload" />
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
   
   <xsl:attribute name="lang">zh</xsl:attribute>

   <center>
   <table border="0" cellspacing="0" cellpadding="0">
      <xsl:if test="param[@id='HTML.WIDTH']">   
      	<xsl:attribute name="width"><xsl:value-of select="param[@id='HTML.WIDTH']" /></xsl:attribute>
      </xsl:if>
      <tr>
         <td colspan="2">
	      	<xsl:if test="lefturls">   
      			<xsl:attribute name="colspan">2</xsl:attribute>
	      	</xsl:if>
		<h2><xsl:value-of select="param[@id='HTML.TITLE']" disable-output-escaping="yes" /></h2>
		<xsl:apply-templates select="topurls" />
         </td>
      </tr>
      <tr>
         <xsl:if test="lefturls"> 
	 <td width="100" valign="top">
		<xsl:apply-templates select="lefturls" />
	 </td>
         </xsl:if>
         <td align="center" valign="top" width="90%" >
	 <div>
	    <xsl:apply-templates select="inputs" />
	    <xsl:apply-templates select="urls" />
   	    <xsl:apply-templates select="webchart" />
	 </div>
	 </td>
      </tr>
   </table>   
   </center>

</body>
</html>
</xsl:template>

<xsl:template match="reload" >
    <script language="JavaScript">
        window.timer=window.setTimeout('window.location.href="<xsl:value-of select="." />";',<xsl:value-of select="@time" /> * 1000);
    </script>
</xsl:template>

<xsl:template match="urls" >
    <div>
    <xsl:for-each select="url">
	<xsl:choose>
	    <xsl:when test="@id = '-' or @sep">   
	    	<xsl:value-of select="." disable-output-escaping="yes" />
	    </xsl:when>
	    <xsl:otherwise>   
	    	<a>
	    		<xsl:attribute name="href"><xsl:value-of select="." /></xsl:attribute>
	    		<xsl:value-of select="@id" />
	    	</a>
	    </xsl:otherwise>
	</xsl:choose>
    </xsl:for-each>
    </div>
</xsl:template>

<xsl:template match="topurls" >
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr height="30">
    <xsl:for-each select="url">
        <td width="80">
	<xsl:choose>
	    <xsl:when test="@id = '-' or @sep">   
	    	<xsl:value-of select="." disable-output-escaping="yes" />
	    </xsl:when>
	    <xsl:otherwise>   
	    	<a>
	    		<xsl:attribute name="href"><xsl:value-of select="." /></xsl:attribute>
	    		<xsl:value-of select="@id" />
	    	</a>
	    </xsl:otherwise>
	</xsl:choose>
        </td>
    </xsl:for-each>
    <td><xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text></td>
    </tr>
    </table>
</xsl:template>

<xsl:template match="lefturls" >
    <p>
    <xsl:for-each select="url">
        <div>
	<xsl:choose>
	    <xsl:when test="@id = '-' or @sep">   
	    	<xsl:value-of select="." disable-output-escaping="yes" />
	    </xsl:when>
	    <xsl:otherwise>   
	    	<a>
	    		<xsl:attribute name="href"><xsl:value-of select="." /></xsl:attribute>
	    		<xsl:value-of select="@id" />
	    	</a>
	    </xsl:otherwise>
	</xsl:choose>
        </div>
    </xsl:for-each>
    </p>
</xsl:template>

<xsl:template match="inputs" >
    <div>
    <form method="POST">
    <xsl:attribute name="action"><xsl:value-of select="//param[@id='REQUEST.FILE']" /></xsl:attribute>
    <xsl:for-each select="item">
    	<xsl:if test="@label">
    		<xsl:value-of select="@label" />
    	</xsl:if>
    	<input>
    		<xsl:attribute name="type"><xsl:value-of select="@type" /></xsl:attribute>
    		<xsl:attribute name="name"><xsl:value-of select="@name" /></xsl:attribute>
    		<xsl:attribute name="value"><xsl:value-of select="@value" /></xsl:attribute>
    		<xsl:if test="@size">
    			<xsl:attribute name="size"><xsl:value-of select="@size" /></xsl:attribute>
    		</xsl:if>
    	</input>
    </xsl:for-each>
    <input type="submit" value="Query" />
    </form>
    </div>
</xsl:template>

<xsl:template match="webchart" >
    <xsl:if test="dataset">
        <table border="1" width="100%" cellspacing="0" cellpadding="2">
            <caption align="center"><font size="5"><xsl:value-of select="title" /></font></caption>
   	    <xsl:apply-templates select="dataset" />
        </table>	
    </xsl:if>
    <xsl:if test="image">
        <xsl:apply-templates select="image" />
    </xsl:if>
</xsl:template>

<xsl:template name="default-dataset" match="dataset" >
 <xsl:choose>
    <xsl:when test="@form">
	<xsl:for-each select="row">
	    <xsl:variable name="rowid"><xsl:value-of select="@id" /></xsl:variable>
	    <xsl:variable name="colcount"><xsl:value-of select="count(col)" /></xsl:variable>
	    <xsl:for-each select="col">
		<xsl:variable name="colid"><xsl:value-of select="@id" /></xsl:variable>
		<xsl:variable name="label"><xsl:value-of select="../../head/col[@id=$colid]/label" /></xsl:variable>
		<tr>
	    	   <xsl:if test="@id = 1">
			<td width="10%" align="center">
				<xsl:attribute name="rowspan">
					<xsl:value-of select="$colcount" />
				</xsl:attribute>
				<xsl:value-of select="$rowid"/>
			</td>
	    	   </xsl:if>
		   <td width="20%" align="center"><xsl:value-of select="$label" disable-output-escaping="yes" /></td>
		   <td><xsl:value-of select="." disable-output-escaping="yes" /></td>
	        </tr>
            </xsl:for-each>
	</xsl:for-each>
    </xsl:when>
    <xsl:otherwise>
	<tr>
	<xsl:for-each select="head/col">
	    <th>
        	<xsl:attribute name="width">
			<xsl:value-of select="@size" />
		</xsl:attribute>
		<xsl:value-of select="label" />
	    </th>
	</xsl:for-each>
	</tr>
	<xsl:for-each select="row">
	    <xsl:variable name="rowid"><xsl:value-of select="@id" /></xsl:variable>
	    <tr>
		<xsl:for-each select="col">
		<xsl:choose>
		    <xsl:when test="@grp">
			<xsl:if test="@grp &gt; 0">
			<td>
			        <xsl:if test="@grp &gt; 1">
				    <xsl:attribute name="rowspan">
					<xsl:value-of select="@grp" />
				    </xsl:attribute>
				</xsl:if>
				<xsl:attribute name="align">
					<xsl:value-of select="@align" />
				</xsl:attribute>
				
				<xsl:choose>
					<xsl:when test="@href">
				    		<a>
							<xsl:attribute name="href">
							    <xsl:value-of select="@href" />
							</xsl:attribute>				    		
				    			<xsl:value-of select="." disable-output-escaping="yes" />
				    		</a>  
		    			</xsl:when>
		    			<xsl:otherwise>				
				    		<xsl:value-of select="." disable-output-escaping="yes" />  
		    			</xsl:otherwise>				
		    		</xsl:choose>
			</td>
			</xsl:if>
		    </xsl:when>
		    <xsl:otherwise>
			<td>
				<xsl:if test="$rowid mod 2 = 1">
					<xsl:attribute name="bgcolor">#eeeeee</xsl:attribute>					
				</xsl:if>
				
				<xsl:attribute name="align">
					<xsl:value-of select="@align" />
				</xsl:attribute>
				
				<xsl:choose>
					<xsl:when test="@href">
				    		<a>
							<xsl:attribute name="href">
								<xsl:value-of select="@href" />
							</xsl:attribute>				    		
				    			<xsl:value-of select="." disable-output-escaping="yes" />
				    		</a>  
		    			</xsl:when>
		    			<xsl:otherwise>				
				    		<xsl:value-of select="." disable-output-escaping="yes" />  
		    			</xsl:otherwise>				
		    		</xsl:choose>
			</td>
		    </xsl:otherwise>
		</xsl:choose>
		</xsl:for-each>
	    </tr>
	</xsl:for-each>
    </xsl:otherwise>
 </xsl:choose>
</xsl:template>

<xsl:template match="image">
   <div style="float:left;">
   <img border="0" align="center" vspace="0">
	<xsl:attribute name="src">
		<xsl:value-of select="file" disable-output-escaping="yes" />
	</xsl:attribute>
	<xsl:attribute name="usemap">#<xsl:value-of select="image_map/@name" /></xsl:attribute> 
   </img>
   <xsl:for-each select="image_map">
      <map>
	<xsl:attribute name="name">
		<xsl:value-of select="@name" />
        </xsl:attribute>
	<xsl:for-each select="mapitem">
	   <area>
	      <xsl:attribute name="title"><xsl:value-of select="title" /></xsl:attribute>
	      <xsl:attribute name="shape"><xsl:value-of select="shape" /></xsl:attribute>
	      <xsl:attribute name="coords"><xsl:value-of select="coords" /></xsl:attribute>
	      <xsl:attribute name="href"><xsl:value-of select="href" /></xsl:attribute>
	  </area>
	</xsl:for-each>
      </map>
    </xsl:for-each>
    </div>
</xsl:template>

</xsl:stylesheet>
