[xsl] Error within cals table xslt

Subject: [xsl] Error within cals table xslt
From: "J. S. Rawat" <jrawat@xxxxxxxxxxxxxx>
Date: Tue, 23 Dec 2008 16:32:27 +0530
Hi
I am getting warning: xsl:variable at line 136 of... "SXWN001: A variable with no following sibling instruction has no effect" while transformation by saxon. It is working fine in altova and other transformation tools. Can anybody help me to correct this.


INPUT:
<chapter>
<table>
<title>Table title</title>
<tgroup cols="2">
<colspec colnum="1" colname="col1"/>
<colspec colnum="2" colname="col2"/>
<thead>
<row>
<entry>Company</entry>
<entry>Pay</entry>
</row>
</thead>
<tbody>
<row>
<entry>Industry Average</entry>
<entry>12.28</entry>
</row>
</tbody>
</tgroup>
</table>
</chapter>

XSLT:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
xmlns:doc="http://nwalsh.com/xsl/documentation/1.0";
exclude-result-prefixes="doc"
version='2.0'>
<xsl:output method="xml"/>
<xsl:template match="chapter">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="table">
<xsl:if test="@type='numbered'">
<div class="divTable">
<table>
<xsl:attribute name="class">numtable</xsl:attribute>
<xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
<xsl:attribute name="cellspacing">0</xsl:attribute>
<xsl:attribute name="cellpadding">2</xsl:attribute>
<xsl:attribute name="width">100%</xsl:attribute>
<xsl:attribute name="border">0</xsl:attribute>
<tbody>
<xsl:apply-templates select="node()"/>
</tbody>
</table>
</div>
</xsl:if>
<xsl:if test="not(@type='numbered')">
<div class="divUnTable">
<table>
<xsl:attribute name="class">unnumtable</xsl:attribute>
<!--<xsl:attribute name="id">utable<xsl:number format="1" count="table[@type='unnumbered']" level="any" from="chapter"/></xsl:attribute>-->
<xsl:attribute name="cellspacing">0</xsl:attribute>
<xsl:attribute name="cellpadding">2</xsl:attribute>
<xsl:attribute name="width">100%</xsl:attribute>
<xsl:attribute name="border">0</xsl:attribute>
<tbody>
<xsl:apply-templates select="node()"/>
</tbody>
</table>
</div>
</xsl:if>
</xsl:template>


<xsl:template match="table/title">
<xsl:if test="text()">
<tr>
<td class="Table_caption">
<xsl:attribute name="colspan"><xsl:value-of select="../tgroup/@cols"/></xsl:attribute>
<xsl:if test="../@extra-info">
<span class="Table_num" readonly="true">
&#160; <xsl:value-of select="../@extra-info"/>
</span>
</xsl:if>
<span class="Table_Caption" notEmpty="true">&#160;
<xsl:apply-templates/>
</span>
</td>
</tr>
</xsl:if>
</xsl:template>


<xsl:template match="table/ftnote">
<tr>
<td class="Table_footnote">
<xsl:attribute name="colspan"><xsl:value-of select="../tgroup/@cols"/></xsl:attribute>
<xsl:apply-templates/>
</td>
</tr>
</xsl:template>


<xsl:template match="table/sourcenote">
<xsl:if test="text()">
<tr>
<td class="Table_source">
<xsl:attribute name="colspan"><xsl:value-of select="../tgroup/@cols"/></xsl:attribute>
<xsl:apply-templates/>
</td>
</tr>
</xsl:if>
</xsl:template>


<xsl:template match="thead">
  <xsl:apply-templates/>
</xsl:template>

<xsl:template match="tbody">
 <xsl:apply-templates/>
</xsl:template>

<xsl:template match="tfoot">
 <xsl:apply-templates/>
</xsl:template>

<xsl:template match="colspec"></xsl:template>
<xsl:template match="spanspec"></xsl:template>

<xsl:template match="row">
 <tr>
  <xsl:if test="@rowsep='1'">
   <xsl:attribute name="class">rowsep</xsl:attribute>
  </xsl:if>
  <xsl:apply-templates/>
 </tr>
</xsl:template>

<xsl:template match="thead/row/entry">
 <xsl:call-template name="process.cell">
  <xsl:with-param name="cellgi">td</xsl:with-param>
 </xsl:call-template>
</xsl:template>

<xsl:template match="tbody/row/entry">
 <xsl:call-template name="process.cell">
  <xsl:with-param name="cellgi">td</xsl:with-param>
 </xsl:call-template>
</xsl:template>

<xsl:template match="tfoot/row/entry">
  <xsl:call-template name="process.cell">
    <xsl:with-param name="cellgi">td</xsl:with-param>
  </xsl:call-template>
</xsl:template>

<xsl:template name="process.cell">
  <xsl:param name="cellgi">td</xsl:param>
  <xsl:variable name="empty.cell" select="count(node()) = 0"/>

  <xsl:variable name="entry.colnum">
    <xsl:call-template name="entry.colnum"/>
  </xsl:variable>

  <xsl:if test="$entry.colnum != ''">
    <xsl:variable name="prev.entry" select="preceding-sibling::*[1]"/>
    <xsl:variable name="prev.ending.colnum">
      <xsl:choose>
        <xsl:when test="$prev.entry">
          <xsl:call-template name="entry.ending.colnum">
            <xsl:with-param name="entry" select="$prev.entry"/>
          </xsl:call-template>
        </xsl:when>
        <xsl:otherwise>0</xsl:otherwise>
      </xsl:choose>
    </xsl:variable>
  </xsl:if>

<xsl:element name="{$cellgi}">

   <xsl:if test="ancestor::thead">
    <xsl:attribute name="class">tch</xsl:attribute>
   </xsl:if>

   <xsl:if test="ancestor::tbody">
    <xsl:attribute name="class">tb</xsl:attribute>
   </xsl:if>

   <xsl:if test="ancestor::tfoot">
    <xsl:attribute name="class">Table_footnote</xsl:attribute>
   </xsl:if>

<xsl:if test="@namest">
<xsl:attribute name="colspan"><xsl:call-template name="calculate.colspan"/></xsl:attribute>
</xsl:if>
<!-- commentd for milkovitch
<xsl:if test="@spanname">
<xsl:variable name="start" select="substring-before(@spanname, 'to')"/>
<xsl:variable name="end" select="substring-after(@spanname, 'to')"/>


<xsl:variable name="colspan" select="$end - $start+1"/>
<xsl:attribute name="colspan"><xsl:value-of select="$end - $start+1"/></xsl:attribute>


<xsl:variable name="spanname" select="@spanname"/>
<xsl:if test="../../../spanspec/@spanname=$spanname">
<xsl:if test="../../../spanspec/@align and @spanname=$spanname">
<xsl:attribute name="align"><xsl:value-of select="../../../spanspec[@spanname=$spanname]/@align"/></xsl:attribute>
</xsl:if>
</xsl:if>
</xsl:if>
-->
<xsl:if test="@morerows">
<xsl:attribute name="rowspan"><xsl:value-of select="@morerows+1"/></xsl:attribute>
</xsl:if>
<xsl:if test="@align">
<xsl:attribute name="align"><xsl:value-of select="@align"/></xsl:attribute>
</xsl:if>
<xsl:if test="@char">
<xsl:attribute name="char"><xsl:value-of select="@char"/></xsl:attribute>
</xsl:if>
<xsl:if test="@charoff">
<xsl:attribute name="charoff"><xsl:value-of select="@charoff"/></xsl:attribute>
</xsl:if>
<xsl:if test="@valign">
<xsl:attribute name="valign"><xsl:value-of select="@valign"/>
</xsl:attribute>
</xsl:if>
<!--
<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>&#160;</xsl:text>
      </xsl:when>
      <xsl:otherwise>
        <xsl:apply-templates/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:element>
</xsl:template>

<xsl:template name="entry.colnum">
  <xsl:param name="entry" select="."/>

<xsl:choose>
<xsl:when test="$entry/@colname">
<xsl:variable name="colname" select="$entry/@colname"/>
<xsl:variable name="colspec" select="$entry/ancestor::tgroup/colspec[@colname=$colname]"/>
<xsl:call-template name="colspec.colnum">
<xsl:with-param name="colspec" select="$colspec"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="$entry/@namest">
<xsl:variable name="namest" select="$entry/@namest"/>
<xsl:variable name="colspec" select="$entry/ancestor::tgroup/colspec[@colname=$namest]"/>
<xsl:call-template name="colspec.colnum">
<xsl:with-param name="colspec" select="$colspec"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="count($entry/preceding-sibling::*) = 0">1</xsl:when>
<xsl:otherwise>
<xsl:variable name="pcol">
<xsl:call-template name="entry.ending.colnum">
<xsl:with-param name="entry" select="$entry/preceding-sibling::*[1]"/>
</xsl:call-template>
</xsl:variable>
<xsl:value-of select="$pcol + 1"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>


<xsl:template name="entry.ending.colnum">
  <xsl:param name="entry" select="."/>

<xsl:choose>
<xsl:when test="$entry/@colname">
<xsl:variable name="colname" select="$entry/@colname"/>
<xsl:variable name="colspec" select="$entry/ancestor::tgroup/colspec[@colname=$colname]"/>
<xsl:call-template name="colspec.colnum">
<xsl:with-param name="colspec" select="$colspec"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="$entry/@nameend">
<xsl:variable name="nameend" select="$entry/@nameend"/>
<xsl:variable name="colspec" select="$entry/ancestor::tgroup/colspec[@colname=$nameend]"/>
<xsl:call-template name="colspec.colnum">
<xsl:with-param name="colspec" select="$colspec"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="count($entry/preceding-sibling::*) = 0">1</xsl:when>
<xsl:otherwise>
<xsl:variable name="pcol">
<xsl:call-template name="entry.ending.colnum">
<xsl:with-param name="entry" select="$entry/preceding-sibling::*[1]"/>
</xsl:call-template>
</xsl:variable>
<xsl:value-of select="$pcol + 1"/>
</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/@colwidth and $use.extensions != 0 and $tablecolumns.extension != 0">
<xsl:attribute name="width">
<xsl:value-of select="$colspec/@colwidth"/>
</xsl:attribute>
</xsl:if>


<xsl:choose>
<xsl:when test="$colspec/@align">
<xsl:attribute name="align"><xsl:value-of select="$colspec/@align"/></xsl:attribute>
</xsl:when>
<xsl:when test="$colspecs/ancestor::tgroup/@align">
<xsl:attribute name="align"><xsl:value-of select="$colspecs/ancestor::tgroup/@align"/></xsl:attribute>
</xsl:when>
</xsl:choose>


<xsl:if test="$colspec/@colwidth">
<xsl:attribute name="width"><xsl:value-of select="$colspec/@width"/></xsl:attribute>
</xsl:if>
<xsl:if test="$colspec/@valign">
<xsl:attribute name="valign"><xsl:value-of select="$colspec/@valign"/></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">
  <xsl:param name="colname"></xsl:param>
  <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 name="calculate.colspan">
  <xsl:param name="entry" select="."/>
  <xsl:variable name="namest" select="$entry/@namest"/>
  <xsl:variable name="nameend" select="$entry/@nameend"/>

<xsl:variable name="scol">
<xsl:call-template name="colspec.colnum">
<xsl:with-param name="colspec" select="$entry/ancestor::tgroup/colspec[@colname=$namest]"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="ecol">
<xsl:call-template name="colspec.colnum">
<xsl:with-param name="colspec" select="$entry/ancestor::tgroup/colspec[@colname=$nameend]"/>
</xsl:call-template>
</xsl:variable>
<xsl:value-of select="$ecol - $scol + 1"/>
</xsl:template>


<xsl:param name="use.extensions" select="'0'" doc:type='boolean'/>

<xsl:param name="default.table.width" select="''" doc:type='length'/>

<xsl:param name="tablecolumns.extension" select="'1'" doc:type='boolean'/>

<xsl:template name="dbhtml-attribute">
  <xsl:param name="pis" select="processing-instruction('dbhtml')"/>
  <xsl:param name="attribute">filename</xsl:param>
  <xsl:param name="count">1</xsl:param>

<xsl:choose>
<xsl:when test="$count &gt; count($pis)">
<!-- not found -->
</xsl:when>
<xsl:otherwise>
<xsl:variable name="pi">
<xsl:value-of select="$pis[$count]"/>
</xsl:variable>
<xsl:choose>
<xsl:when test="contains($pi,concat($attribute, '='))">
<xsl:variable name="rest" select="substring-after($pi,concat($attribute,'='))"/>
<xsl:variable name="quote" select="substring($rest,1,1)"/>
<xsl:value-of select="substring-before(substring($rest,2),$quote)"/>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="dbhtml-attribute">
<xsl:with-param name="pis" select="$pis"/>
<xsl:with-param name="attribute" select="$attribute"/>
<xsl:with-param name="count" select="$count + 1"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:template>


</xsl:stylesheet>

Thanks in advance!!!
...JSR

Current Thread