Dear All,
We have found solution. Hope this will helps someone.
<!--if the entry element has align attribute then select that attribute otherwise select tgroup colspec element whose colname attribute should match with entry colname i.e., ancestor::tgroup/colspec[@colname=current()/@colname]/@align-->
<xsl:choose>
<xsl:when test="string-length(@align)">
<xsl:attribute name="align">
<xsl:value-of select="@align"/>
</xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="align">
<xsl:variable name="colspe" select="entry[@colname]"/>
<xsl:value-of select="ancestor::tgroup/colspec[@colname=current()/@colname]/@align"/>
</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
XSL Code:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:param name="default.table.width" select="'100%'"/>
<xsl:template match="table">
<xsl:variable name="tborder1">
<xsl:choose>
<xsl:when test="@frame='all'">border-top: 2px solid #ff0000; border-bottom: 2px solid #ff0000; border-left: 2px solid #ff0000; border-right: 2px solid #ff0000;</xsl:when>
<xsl:when test="@frame='topbot'">border-top: 2px solid #ff0000; border-bottom: 2px solid #ff0000;</xsl:when>
<xsl:when test="@frame='top'">border-top: 2px solid #ff0000;</xsl:when>
<xsl:when test="@frame='bottom'">border-bottom: 2px solid #ff0000;</xsl:when>
<xsl:when test="@frame='leftright'">border-left: 2px solid #ff0000; border-right: 2px solid #ff0000;</xsl:when>
<xsl:when test="@frame='left'">border-left: 2px solid #ff0000;</xsl:when>
<xsl:when test="@frame='right'">border-right: 2px solid #ff0000;</xsl:when>
<xsl:otherwise>0px 0px 0px 0px solid #000000;</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<br/><table bgcolor="#ffdecc" border="1" cellpadding="5" width="100%" align="center" cellspacing="0" style="{$tborder1}">
<xsl:apply-templates/>
</table><br/>
</xsl:template>
<xsl:template match="tgroup">
<br/>
<xsl:if test="../@pgwide=1">
</xsl:if>
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="tbody">
<xsl:choose>
<xsl:when test="@valign='top'">
<tbody valign="top">
<xsl:apply-templates/>
</tbody>
</xsl:when>
<xsl:when test="@valign='middle'">
<tbody valign="middle">
<xsl:apply-templates/>
</tbody>
</xsl:when>
<xsl:otherwise>
<tbody valign="bottom">
<xsl:apply-templates/>
</tbody>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="thead">
<xsl:choose>
<xsl:when test="@valign='top'">
<thead valign="top">
<xsl:apply-templates/>
</thead>
</xsl:when>
<xsl:when test="@valign='middle'">
<thead valign="middle">
<xsl:apply-templates/>
</thead>
</xsl:when>
<xsl:otherwise>
<thead valign="bottom">
<xsl:apply-templates/>
</thead>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="row">
<tr>
<xsl:apply-templates/>
</tr>
</xsl:template>
<xsl:template match="entry">
<xsl:choose>
<xsl:when test="ancestor::tbody">
<xsl:call-template name="process.cell">
<xsl:with-param name="cellgi">td</xsl:with-param>
</xsl:call-template>
</xsl:when>
<xsl:when test="ancestor::thead">
<xsl:call-template name="process.cell">
<xsl:with-param name="cellgi">th</xsl:with-param>
</xsl:call-template>
</xsl:when>
<xsl:when test="ancestor::tfoot">
<xsl:call-template name="process.cell">
<xsl:with-param name="cellgi">th</xsl:with-param>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="name(preceding-sibling::*[1])"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="process.cell">
<xsl:param name="cellgi">td</xsl:param>
<xsl:variable name="empty.cell" select="count(node()) = 0"/>
<xsl:element name="{$cellgi}">
<xsl:if test="@namest">
<xsl:attribute name="colspan"><xsl:value-of select="(@nameend) + (-(@namest)) + 1"/></xsl:attribute>
</xsl:if>
<xsl:if test="@morerows">
<xsl:attribute name="rowspan">
<xsl:value-of select="@morerows+1"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="@valign">
<xsl:attribute name="valign">
<xsl:value-of select="@valign"/>
</xsl:attribute>
</xsl:if>
<xsl:attribute name="width">
<xsl:variable name="currColumn" select="@colname"/>
<xsl:variable name="colwidth" select="ancestor::tgroup/colspec[@colname=$currColumn]/@colwidth"/>
<xsl:choose>
<xsl:when test="ends-with($colwidth, '*')">
<xsl:value-of select="replace($colwidth, '\*', '%')"/>
</xsl:when>
<xsl:when test="not(ends-with($colwidth, '*'))">
<xsl:value-of select="$colwidth"/><xsl:text>%</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$colwidth"/>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<xsl:choose>
<xsl:when test="string-length(@align)">
<xsl:attribute name="align">
<xsl:value-of select="@align"/>
</xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="align">
<xsl:variable name="colspe" select="entry[@colname]"/>
<xsl:value-of select="ancestor::tgroup/colspec[@colname=current()/@colname]/@align"/>
</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test="(@rowsep='1') and (@colsep='1')">
<xsl:attribute name="style">border-bottom:2px solid #0000ff; border-right:2px solid #0000ff</xsl:attribute>
</xsl:when>
<xsl:when test="(@rowsep='1') and (@colsep='0')">
<xsl:attribute name="style">border-bottom:2px solid #0000ff</xsl:attribute>
</xsl:when>
<xsl:when test="(@rowsep=0) and (@colsep=1)">
<xsl:attribute name="style">border-right:2px solid #0000ff</xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="style">border: 0px 0px 0px 0pxsolid #0000ff;</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
<xsl:if test="not(preceding-sibling::*)
and ancestor::row/@id">
<a name="{ancestor::row/@id}"/>
</xsl:if>
<xsl:if test="@id">
<a name="{@id}"/>
</xsl:if>
<xsl:choose>
<xsl:when test="$empty.cell">
<xsl:text> </xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates/>
</xsl:otherwise>
</xsl:choose>
</xsl:element>
</xsl:template>
<xsl:template name="add-empty-entries">
<xsl:param name="number" select="'0'"/>
<xsl:choose>
<xsl:when test="$number <= 0"></xsl:when>
<xsl:otherwise>
<td> </td>
<xsl:call-template name="add-empty-entries">
<xsl:with-param name="number" select="$number - 1"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="colspec.colnum">
<xsl:param name="colspec" select="."/>
<xsl:choose>
<xsl:when test="$colspec/@colnum">
<xsl:value-of select="$colspec/@colnum"/>
</xsl:when>
<xsl:when test="$colspec/preceding-sibling::colspec">
<xsl:variable name="prec.colspec.colnum">
<xsl:call-template name="colspec.colnum">
<xsl:with-param name="colspec" select="$colspec/preceding-sibling::colspec[1]"/>
</xsl:call-template>
</xsl:variable>
<xsl:value-of select="$prec.colspec.colnum + 1"/>
</xsl:when>
<xsl:otherwise>1</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="generate.colgroup">
<xsl:param name="cols" select="1"/>
<xsl:param name="count" select="1"/>
<xsl:choose>
<xsl:when test="$count>$cols"></xsl:when>
<xsl:otherwise>
<xsl:call-template name="generate.col">
<xsl:with-param name="countcol" select="$count"/>
</xsl:call-template>
<xsl:call-template name="generate.colgroup">
<xsl:with-param name="cols" select="$cols"/>
<xsl:with-param name="count" select="$count+1"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="generate.col">
<xsl:param name="countcol">1</xsl:param>
<xsl:param name="colspecs" select="./colspec"/>
<xsl:param name="count">1</xsl:param>
<xsl:param name="colnum">1</xsl:param>
<xsl:choose>
<xsl:when test="$count>count($colspecs)">
<col/>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="colspec" select="$colspecs[$count=position()]"/>
<xsl:variable name="colspec.colnum">
<xsl:choose>
<xsl:when test="$colspec/@colnum">
<xsl:value-of select="$colspec/@colnum"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$colnum"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:choose>
<xsl:when test="$colspec.colnum=$countcol">
<col>
<xsl:if test="$colspec/@align">
<xsl:attribute name="align">
<xsl:value-of select="$colspec/@align"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="$colspec/@char">
<xsl:attribute name="char">
<xsl:value-of select="$colspec/@char"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="$colspec/@charoff">
<xsl:attribute name="charoff">
<xsl:value-of select="$colspec/@charoff"/>
</xsl:attribute>
</xsl:if>
</col>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="generate.col">
<xsl:with-param name="countcol" select="$countcol"/>
<xsl:with-param name="colspecs" select="$colspecs"/>
<xsl:with-param name="count" select="$count+1"/>
<xsl:with-param name="colnum">
<xsl:choose>
<xsl:when test="$colspec/@colnum">
<xsl:value-of select="$colspec/@colnum + 1"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$colnum + 1"/>
</xsl:otherwise>
</xsl:choose>
</xsl:with-param>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="colspec.colwidth">
<!-- when this macro is called, the current context must be an entry -->
<xsl:param name="colname"></xsl:param>
<!-- .. = row, ../.. = thead|tbody, ../../.. = tgroup -->
<xsl:param name="colspecs" select="../../../../tgroup/colspec"/>
<xsl:param name="count">1</xsl:param>
<xsl:choose>
<xsl:when test="$count>count($colspecs)"></xsl:when>
<xsl:otherwise>
<xsl:variable name="colspec" select="$colspecs[$count=position()]"/>
<xsl:choose>
<xsl:when test="$colspec/@colname=$colname">
<xsl:value-of select="$colspec/@colwidth"/>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="colspec.colwidth">
<xsl:with-param name="colname" select="$colname"/>
<xsl:with-param name="colspecs" select="$colspecs"/>
<xsl:with-param name="count" select="$count+1"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="nl">
<br/><xsl:apply-templates/>
</xsl:template>
</xsl:stylesheet>
Note: If it helps then vote thanks.
Thanks,
Ram