			border-width: 1px;
				border-color: black;
				
				<xsl:variable name='frame' select='ancestor::table/@frame'/>
				<xsl:choose>
					<xsl:when test='$frame="sides"'>
						border-left-style: solid;
						border-right-style: solid;
						border-top-style: hidden;
						border-bottom-style: hidden;
					</xsl:when>
					<xsl:when test='$frame="topbot"'>
						border-left-style: none;
						border-right-style: none;
						border-top-style: hidden;
						border-bottom-style: hidden;
					</xsl:when>
					<xsl:when test='$frame="top"'>
						border-left-style: hidden;
						border-right-style: hidden;
						border-top-style: solid;
						border-bottom-style: hidden;
					</xsl:when>
					<xsl:when test='$frame="bottom"'>
						border-left-style: hidden;
						border-right-style: hidden;
						border-top-style: hidden;
						border-bottom-style: solid;
					</xsl:when>
					<xsl:when test='$frame="none"'>
						border-left-style: hidden;
						border-right-style: hidden;
						border-top-style: hidden;
						border-bottom-style: hidden;
					</xsl:when>
					<xsl:otherwise>
						border-left-style: solid;
						border-right-style: solid;
						border-top-style: solid;
						border-bottom-style: solid;
					</xsl:otherwise>
				</xsl:choose>
			</xsl:attribute>
		
			<!-- transform colspecs -->
			<xsl:for-each select='colspec'>
				<col>
				
					<!-- handle width property -->
					<xsl:variable name='colwidth' select='@colwidth'/>
					<xsl:choose>
                        <!-- "*" or empty colwidth attributes are equivalent to "1*" -->
                        <!-- mixed measure colwidths are handled as if they were "1*" -->
						<xsl:when test='contains($colwidth,"+") or not($colwidth) or $colwidth="*"'>
							<xsl:attribute name='width'>1*</xsl:attribute>
						</xsl:when>
						<xsl:when test='contains($colwidth,"*")'>
							<xsl:attribute name='width'><xsl:value-of select='$colwidth'/></xsl:attribute>
						</xsl:when>
						<xsl:otherwise>
							<xsl:attribute name="style">width: 
								<xsl:choose>
									<xsl:when test='contains($colwidth,"pi")'>
										<!-- CALS and CSS use different abbreviations for picas -->
										<xsl:value-of select='translate($colwidth,"i","c")'/>
									</xsl:when>
									<xsl:otherwise>
										<xsl:value-of select='$colwidth'/>
									</xsl:otherwise>
								</xsl:choose>
							</xsl:attribute>
						</xsl:otherwise>
					</xsl:choose>
					
				</col>
			</xsl:for-each>
			
			<!-- transform rows -->
			<xsl:for-each select='thead|tfoot|tbody'>
				<xsl:copy>
					<xsl:for-each select='row'>
						<tr>
							<!-- transform cells -->
							<xsl:for-each select='entry|entrytbl'>
								<xsl:call-template name='transformCALSCell'/>
							</xsl:for-each>
						</tr>
					</xsl:for-each>
				</xsl:copy>
			</xsl:for-each>
		</table>
	</xsl:template>
	
	<xsl:template name='transformCALSCell'>
		<td>
			<!-- handle horizontal extension of the cell -->
			<xsl:variable name='spanname' select='@spanname'/>
			<xsl:variable name='namest' select='@namest'/>
			<xsl:variable name='nameend' select='@nameend'/>
			
			<xsl:choose>
				<xsl:when test='$spanname'>
					<xsl:variable name='spanspec' select='ancestor::*[spanspec][1]/spanspec[@spanname=$spanname]'/>
					<xsl:variable name='namest_2' select='$spanspec/@namest'/>
					<xsl:variable name='nameend_2' select='$spanspec/@nameend'/>
					
					<xsl:variable name='startColumn' select='count(ancestor::*[colspec][1]/colspec[@colname=$namest_2]/preceding-sibling::*)'/>
					<xsl:variable name='endColumn' select='count(ancestor::*[colspec][1]/colspec[@colname=$nameend_2]/preceding-sibling::*)'/>
					
					<xsl:attribute name='colspan'><xsl:value-of select='$endColumn - $startColumn + 1'/></xsl:attribute>
					
				</xsl:when>
				
				<xsl:when test='$namest and $nameend'>
					<xsl:variable name='startColumn' select='count(ancestor::*[colspec][1]/colspec[@colname=$namest]/preceding-sibling::*)'/>
					<xsl:variable name='endColumn' select='count(ancestor::*[colspec][1]/colspec[@colname=$nameend]/preceding-sibling::*)'/>
					
					<xsl:attribute name='colspan'><xsl:value-of select='$endColumn - $startColumn + 1'/></xsl:attribute>
				</xsl:when>
			</xsl:choose>
			
			<!-- handle vertical extension of the cell -->
			<xsl:variable name='morerows' select='@morerows'/>
			<xsl:if test='$morerows'>
				<xsl:attribute name='rowspan'><xsl:value-of select='$morerows+1'/></xsl:attribute>
			</xsl:if>
			
			<!-- handle horizontal alignment -->
			<xsl:call-template name='findInheritedAttribute'>
				<xsl:with-param name='attributeName'>align</xsl:with-param>
			</xsl:call-template>
			<xsl:call-template name='findInheritedAttribute'>
				<xsl:with-param name='attributeName'>char</xsl:with-param>
			</xsl:call-template>
			<xsl:call-template name='findInheritedAttribute'>
				<xsl:with-param name='attributeName'>charoff</xsl:with-param>
			</xsl:call-template>
			
			<!-- handle verical alignment -->
			<xsl:variable name='valign' select='ancestor-or-self::*[@valign][1]/@valign'/>
			<xsl:attribute name='valign'>
				<xsl:choose>
					<xsl:when test='$valign'>
						<xsl:value-of select='$valign'/>
					</xsl:when>
					<xsl:otherwise>
						<!-- the default vertical alignment depends on whether
						     this cell is the the table header, footer or body -->
						<xsl:choose>
							<xsl:when test='parent::*/parent::thead'>
								bottom
							</xsl:when>
							<xsl:otherwise>
								top
							</xsl:otherwise>
						</xsl:choose>
					</xsl:otherwise>
				</xsl:choose>
			</xsl:attribute>
			
			<!-- handle borders -->
			<xsl:attribute name='style'>
				border-width: 1px;
				border-color: black;
				
				<xsl:call-template name='findInheritedAttribute'>
					<xsl:with-param name='attributeName'>colsep</xsl:with-param>
				</xsl:call-template>
				
				<xsl:call-template name='findInheritedAttribute'>
					<xsl:with-param name='attributeName'>rowsep</xsl:with-param>
				</xsl:call-template>
			</xsl:attribute>
			
			<!-- transform cell content -->
			<xsl:apply-templates select='.'/>
		</td>
	</xsl:template>
	
	<!-- If the context node is an entry or entrytbl, searches for the value of an
	     inherited attribute by following the normal inheritance path.  If a
	     value is found, calls tranformInheritedAttribute with attributeName
	     passes as is and attributeValue set to the found value; otherwise, calls
	     tranformInheritedAttribute with attributeValue set to the empty string.
	     
	     Parameter attributeName is the name of the attribute found.
     -->
	
	<xsl:template name='findInheritedAttribute'>
		<xsl:param name='attributeName'/>
		
		<xsl:variable name='colname' select='@colname'/>
		<xsl:variable name='colname_colspec' select='ancestor::*[colspec][1]/colspec[@colname=$colname]'/>
		
		<xsl:variable name='namest' select='@namest'/>
		<xsl:variable name='namest_colspec' select='ancestor::*[colspec][1]/colspec[@colna