<?xml version="1.0"?>

<!-- ============================================================ -->
<!--                                                              -->
<!-- 	This file makes a part of RenderX XSL Test Suite          -->
<!--                                                              -->
<!--    Author: Alexander Peshkov                                 -->
<!--                                                              -->
<!--    (c) RenderX, 2003                                         -->
<!--                                                              -->
<!-- ============================================================ -->

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                			  xmlns:fo="http://www.w3.org/1999/XSL/Format"
                			  xmlns:rx="http://www.renderx.com/XSL/Extensions">
	
	<xsl:import href="generic.xsl"/>
	<xsl:output method="xml" indent="yes"/>

	<xsl:template match="table">
	 <fo:table-and-caption break-before="page">
	  <fo:table-caption> 
	  	<fo:block font="bold 10pt Helvetica" keep-with-next="always" space-before="16pt" space-after="6pt" text-align="end">
	  		<xsl:value-of select="table-caption"/>
	  	</fo:block>
	  </fo:table-caption>
	  <fo:table>
        <xsl:if test="@continuous='true'">
          <xsl:attribute name="rx:table-omit-initial-header">true</xsl:attribute>
        </xsl:if>
  	    <xsl:apply-templates select="colspec"/>
  	    <xsl:choose>
  	  	  <xsl:when test="@continuous='true'">
  	  		  <xsl:apply-templates select="table-header" mode="no-repeat">
  	  		  	<xsl:with-param name="caption" select="table-caption"/>
  	  		  	<xsl:with-param name="columns" select="count(colspec)"/>
  	  		  </xsl:apply-templates>
  	  	  </xsl:when>
  	  	  <xsl:otherwise>
  	  		  <xsl:apply-templates select="table-header"/>
  	  	  </xsl:otherwise>
  	    </xsl:choose>
  	    <xsl:apply-templates select="table-body"/>
      </fo:table>
	 </fo:table-and-caption>
	</xsl:template>

	<xsl:template match="table-header" mode="no-repeat">
	  <xsl:param name="caption" select="''"/>
	  <xsl:param name="columns" select="1"/>
	  <fo:table-header background-color="silver" font-size="110%" font-weight="bold">
	    <xsl:if test="$caption!=''">    
	      <fo:table-row background-color="white" keep-with-next="always">
	  	  	<fo:table-cell padding="3pt"
            			   text-align="end"
            			   number-columns-spanned="{$columns}">
              <fo:block font="bold 10pt Helvetica" text-align="end">
                <xsl:value-of select="$caption"/>
                <fo:inline font-style="italic" font-weight="normal"> (Continued)</fo:inline>
              </fo:block>
	  	    </fo:table-cell>	    	
	      </fo:table-row>
	    </xsl:if>
	    <xsl:apply-templates/>
	  </fo:table-header>
	  <fo:table-body background-color="silver" font-size="110%" font-weight="bold">
	    <xsl:apply-templates/>
	  </fo:table-body>
	</xsl:template>

	
</xsl:stylesheet>