Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old January 16th, 2014, 09:29 AM
Authorized User
Points: 151, Level: 3
Points: 151, Level: 3 Points: 151, Level: 3 Points: 151, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2013
Posts: 31
Thanks: 3
Thanked 0 Times in 0 Posts
Default CALS Table not properly getting created

I've the below XML code(Tables)

HTML Code:
<root>
  <table frame="all">
    <tgroup cols="9">
      <colspec colname="col1" colnum="1" colwidth="9*"/>
      <colspec colname="col2" colnum="2" colwidth="12*"/>
      <colspec colname="col3" colnum="3" colwidth="14*"/>
      <colspec colname="col4" colnum="4" colwidth="10*"/>
      <colspec colname="col5" colnum="5" colwidth="11*"/>
      <colspec colname="col6" colnum="6" colwidth="11*"/>
      <colspec colname="col7" colnum="7" colwidth="11*"/>
      <colspec colname="col8" colnum="8" colwidth="11*"/>
      <colspec colname="col9" colnum="9" colwidth="11*"/>
    <tbody>
      <row rowsep="1">
        <entry colname="col1" align="center" valign="top" colsep="1"><para>BIL</para></entry>
        <entry colname="col2" align="center" valign="top" colsep="1"><para>NO KES</para></entry>
        <entry colname="col3" align="center" valign="top" colsep="1"><para>NAMA PEMBELI</para></entry>
        <entry colname="col4" align="center" valign="top" colsep="1"><para>NO. KP</para></entry>
        <entry colname="col5" align="center" valign="top" colsep="1"><para>ALAMAT PEMBELI</para></entry>
        <entry colname="col6" align="center" valign="top" colsep="1"><para>TARIKH LELONG</para></entry>
        <entry colname="col7" align="center" valign="top" colsep="1"><para>TARIKH LUPUT</para></entry>
        <entry colname="col8" align="center" valign="top" colsep="1"><para>HARGA RIZAB</para></entry>
        <entry colname="col9" align="center" valign="top"><para>HARGA JUALAN</para></entry>
      </row>
      <row rowsep="1">
        <entry colname="col1" align="left" valign="top" colsep="1"><para></para></entry>
        <entry colname="col2" align="left" valign="top" colsep="1"><para></para></entry>
        <entry colname="col3" align="left" valign="top" colsep="1"><para></para></entry>
        <entry colname="col4" align="left" valign="top" colsep="1"><para></para></entry>
        <entry colname="col5" align="left" valign="top" colsep="1"><para></para></entry>
        <entry colname="col6" align="left" valign="top" colsep="1"><para></para></entry>
        <entry colname="col7" align="left" valign="top" colsep="1"><para></para></entry>
        <entry colname="col8" align="left" valign="top" colsep="1"><para></para></entry>
        <entry colname="col9" align="left" valign="top"><para></para></entry>
      </row>
      <row>
        <entry colname="col1" align="left" valign="top" colsep="1"><para></para></entry>
        <entry colname="col2" align="left" valign="top" colsep="1"><para></para></entry>
        <entry colname="col3" align="left" valign="top" colsep="1"><para></para></entry>
        <entry colname="col4" align="left" valign="top" colsep="1"><para></para></entry>
        <entry colname="col5" align="left" valign="top" colsep="1"><para></para></entry>
        <entry colname="col6" align="left" valign="top" colsep="1"><para></para></entry>
        <entry colname="col7" align="left" valign="top" colsep="1"><para></para></entry>
        <entry colname="col8" align="left" valign="top" colsep="1"><para></para></entry>
        <entry colname="col9" align="left" valign="top"><para></para></entry>
      </row>
    </tbody>
  </tgroup>
</table>

<table frame="all">
  <tgroup cols="9">
    <colspec colname="col1" colnum="1" colwidth="6*"/>
    <colspec colname="col2" colnum="2" colwidth="6*"/>
    <colspec colname="col3" colnum="3" colwidth="6*"/>
    <colspec colname="col4" colnum="4" colwidth="6*"/>
    <colspec colname="col5" colnum="5" colwidth="7*"/>
    <colspec colname="col6" colnum="6" colwidth="7*"/>
    <colspec colname="col7" colnum="7" colwidth="25*"/>
    <colspec colname="col8" colnum="8" colwidth="10*"/>
    <colspec colname="col9" colnum="9" colwidth="15*"/>
  <tbody>
    <row>
      <entry namest="col1" nameend="col3" align="center" valign="top" colsep="1"><para>DEPOSIT 10% HARGA RIZAB</para></entry>
      <entry namest="col4" nameend="col6" align="center" valign="top" colsep="1"><para>BAKI 90% HARGA BELIAN</para></entry>
      <entry colname="col7" align="left" valign="top" colsep="1" rowsep="1" morerows="1"><para>TARIKH PEMYATA BAILIF DAN BAUCARDISEDIAKAN</para></entry>
      <entry colname="col8" align="left" valign="top" colsep="1" rowsep="1" morerows="1"><para>TARIKH PENYATA DAN TARIKH BAUCAR DIHANTAR KE BAHAGIAN KEWANGAN</para></entry>
      <entry colname="col9" align="left" valign="top" rowsep="1" morerows="1"><para>TARIK CEK BAYARAN DIKELUARKAN/DIHANTAR KEPADA PENAWAR</para></entry>
    </row>
    <row rowsep="1">
      <entry colname="col1" align="center" valign="top"><para>Tarikh</para></entry>
      <entry colname="col2" align="center" valign="top"><para>No. Resit</para></entry>
      <entry colname="col3" align="center" valign="top" colsep="1"><para>Jumlah</para></entry>
      <entry colname="col4" align="left" valign="top"><para>Tarikh</para></entry>
      <entry colname="col5" align="center" valign="top"><para>No. Resit</para></entry>
      <entry colname="col6" align="center" valign="top" colsep="1"><para>Jumlah</para></entry>
      <entry colname="col7" align="left" valign="top"><para></para></entry>
      <entry colname="col8" align="left" valign="top"><para></para></entry>
      <entry colname="col9" align="left" valign="top"><para></para></entry>
    </row>
    <row>
      <entry colname="col1" align="left" valign="top" colsep="1"><para></para></entry>
      <entry colname="col2" align="left" valign="top" colsep="1"><para></para></entry>
      <entry colname="col3" align="left" valign="top" colsep="1"><para></para></entry>
      <entry colname="col4" align="left" valign="top" colsep="1"><para></para></entry>
      <entry colname="col5" align="left" valign="top" colsep="1"><para></para></entry>
      <entry colname="col6" align="left" valign="top" colsep="1"><para></para></entry>
      <entry colname="col7" align="left" valign="top" colsep="1"><para></para></entry>
      <entry colname="col8" align="left" valign="top" colsep="1"><para></para></entry>
      <entry colname="col9" align="left" valign="top"><para></para></entry>
    </row>
  </tbody>
</tgroup>
</table>
</root>
And I'm using the XSLT below:

HTML Code:
<xsl:template name="table" match="table">
    <table class="frame-{current()/@frame}">
      <xsl:apply-templates/>
    </table>
  </xsl:template>


  <xsl:template match="tgroup">
  <xsl:if test="not(preceding-sibling::tgroup)">
  <xsl:if test="@colsep|@rowsep|@align|cols">

</xsl:if>
</xsl:if>


    <colgroup>
      <xsl:apply-templates select=".//colspec" />
    </colgroup>
    <xsl:apply-templates select="child::node()[not(self::colspec)]" />
  </xsl:template>
  <xsl:template name="tbody" match="tgroup/tbody">
    <tbody>
      <xsl:for-each select="current()/row">
        <xsl:call-template name="row" />
      </xsl:for-each>
    </tbody>
  </xsl:template>
  <xsl:template name="thead" match="tgroup/thead">

    <xsl:for-each select="current()/row">
      <thead>
        <tr>
          <xsl:for-each select="current()/entry">
            <xsl:call-template name="headentry" />
          </xsl:for-each>
        </tr>
      </thead>
    </xsl:for-each>
  </xsl:template>





  <xsl:template name="colspec" match="colspec">


    <xsl:variable name="b">
      <xsl:value-of select="sum(../colspec/number(substring-before(@colwidth,'in')))"/>
    </xsl:variable>

    <xsl:choose>
      <xsl:when test="@colnum">
        <col class="colnum-{current()/@colnum} colname-{current()/@colname} colwidth-{translate(@colwidth,'*','')}" />
      </xsl:when>
      <xsl:otherwise>
        <col class="colname-{current()/@colname} colwidth-{translate(@colwidth,'*','')}" />
      </xsl:otherwise>
    </xsl:choose>
    <xsl:text disable-output-escaping="yes"><![CDATA[</col>]]></xsl:text>
  </xsl:template>
  <xsl:template name="row" match="tbody/row">
    <tr>
      <xsl:for-each select="current()/entry">
        <xsl:call-template name="entry" />
      </xsl:for-each>
    </tr>
  </xsl:template>


  <xsl:template match="entry" name="entry">

  <xsl:choose>

  <xsl:when test="./@namest">
            <xsl:variable name="namest" select="@namest"/>
    <xsl:variable name="nameend" select="@nameend"/>
    <xsl:variable name="namestPos" select="count(ancestor::tgroup/colspec[@colname=$namest]/preceding-sibling::colspec)"/>
    <xsl:variable name="nameendPos" select="count(ancestor::tgroup/colspec[@colname=$nameend]/preceding-sibling::colspec)"/>

    <td colspan="{$nameendPos - $namestPos + 1}" align="{@align}" valign="{@valign}">

      <xsl:apply-templates/>
    </td>
        </xsl:when>
        <xsl:when test="@align and ./@morerows">
        <td class="align-{@align}" rowspan="{number(./@morerows)+1}"  valign="{@valign}">
        <xsl:for-each select="para">
<xsl:choose>
    <xsl:when test="../@colname='col4' and contains(./text(),'/')">
        <xsl:value-of select="concat('er:#MCP_PD_',substring-before(.,'/'),'/','P',translate(./text(),'/','-'))"/>
    </xsl:when>
    <xsl:otherwise>
          <div class="para">
            <xsl:apply-templates/>
          </div>
    </xsl:otherwise>
</xsl:choose>

          </xsl:for-each>
        </td>
      </xsl:when>
      <xsl:when test="./@morerows and not(./@align)">
                          <td rowspan="{number(./@morerows)+1}"  valign="{@valign}">
<xsl:for-each select="para">         
         <xsl:choose>
    <xsl:when test="../@colname='col4' and contains(./text(),'/')">
    <xsl:value-of select="concat('er:#MCP_PD_',substring-before(.,'/'),'/','P',translate(./text(),'/','-'))"/>
    </xsl:when>
    <xsl:otherwise>
          <div class="para">
            <xsl:apply-templates/>
          </div>
    </xsl:otherwise>
</xsl:choose></xsl:for-each>
        </td>
        </xsl:when>

      <xsl:otherwise>
        <td class="align-{@align}" valign="{@valign}">
        <xsl:for-each select="para">

       <xsl:choose>
    <xsl:when test="../@colname='col4' and contains(./text(),'/')">
        <a href="{concat('er:#MCP_PD_',substring-before(.,'/'),'/','P',translate(./text(),'/','-'))}">
<xsl:value-of select="./text()"/>       
        </a>
    </xsl:when>
    <xsl:otherwise>
          <div class="para">
            <xsl:apply-templates/>
          </div>
    </xsl:otherwise>
</xsl:choose>
          </xsl:for-each>
        </td>
      </xsl:otherwise>
    </xsl:choose>

  </xsl:template>



  <xsl:template name="headentry">
    <xsl:choose>
      <xsl:when test="@align">
        <th class="align-{@align}"  valign="{@valign}
">
          <xsl:if test="translate(current()/@namest,'col','') != translate(current()/@nameend,'col','')">
            <xsl:variable name="colspan">
              <xsl:value-of select="number(translate(@nameend,'col','')) - number(translate(@namest,'col','')) + 1" />
            </xsl:variable>
            <xsl:attribute name="colspan">
              <xsl:value-of select="$colspan">
              </xsl:value-of>
            </xsl:attribute>
          </xsl:if>
          <xsl:for-each select="para">
            <div class="para">
              <xsl:apply-templates></xsl:apply-templates>
            </div>
          </xsl:for-each>
        </th>
      </xsl:when>
      <xsl:otherwise>
        <th>
          <xsl:if test="translate(current()/@namest,'col','') != translate(current()/@nameend,'col','')">
            <xsl:variable name="colspan">
           <!--   <xsl:value-of select="translate(current()/@nameend,'col','') - translate(current()/@namest,'col','') + 1" />-->
            </xsl:variable>
            <xsl:attribute name="colspan">
              <xsl:value-of select="$colspan">
              </xsl:value-of>
            </xsl:attribute>
          </xsl:if>
          <xsl:for-each select="para">
            <div class="para">
              <xsl:apply-templates></xsl:apply-templates>
            </div>
          </xsl:for-each>
        </th>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>
the html code of output is as below.

HTML Code:
<table class="frame-all">
                        <colgroup>
                            <col class="colnum-1 colname-col1 colwidth-9"></col><col class="colnum-2 colname-col2 colwidth-12"></col><col class="colnum-3 colname-col3 colwidth-14"></col><col class="colnum-4 colname-col4 colwidth-10"></col><col class="colnum-5 colname-col5 colwidth-11"></col><col class="colnum-6 colname-col6 colwidth-11"></col><col class="colnum-7 colname-col7 colwidth-11"></col><col class="colnum-8 colname-col8 colwidth-11"></col><col class="colnum-9 colname-col9 colwidth-11"></col></colgroup>
                        <tbody>
                            <tr>
                                <td class="align-center" valign="top">
                                    <div class="para">BIL</div>
                                </td>
                                <td class="align-center" valign="top">
                                    <div class="para">NO KES</div>
                                </td>
                                <td class="align-center" valign="top">
                                    <div class="para">NAMA PEMBELI</div>
                                </td>
                                <td class="align-center" valign="top">
                                    <div class="para">NO. KP</div>
                                </td>
                                <td class="align-center" valign="top">
                                    <div class="para">ALAMAT PEMBELI</div>
                                </td>
                                <td class="align-center" valign="top">
                                    <div class="para">TARIKH LELONG</div>
                                </td>
                                <td class="align-center" valign="top">
                                    <div class="para">TARIKH LUPUT</div>
                                </td>
                                <td class="align-center" valign="top">
                                    <div class="para">HARGA RIZAB</div>
                                </td>
                                <td class="align-center" valign="top">
                                    <div class="para">HARGA JUALAN</div>
                                </td>
                            </tr>
                            <tr>
                                <td class="align-left" valign="top">
                                    <div class="para"></div>
                                </td>
                                <td class="align-left" valign="top">
                                    <div class="para"></div>
                                </td>
                                <td class="align-left" valign="top">
                                    <div class="para"></div>
                                </td>
                                <td class="align-left" valign="top">
                                    <div class="para"></div>
                                </td>
                                <td class="align-left" valign="top">
                                    <div class="para"></div>
                                </td>
                                <td class="align-left" valign="top">
                                    <div class="para"></div>
                                </td>
                                <td class="align-left" valign="top">
                                    <div class="para"></div>
                                </td>
                                <td class="align-left" valign="top">
                                    <div class="para"></div>
                                </td>
                                <td class="align-left" valign="top">
                                    <div class="para"></div>
                                </td>
                            </tr>
                            <tr>
                                <td class="align-left" valign="top">
                                    <div class="para"></div>
                                </td>
                                <td class="align-left" valign="top">
                                    <div class="para"></div>
                                </td>
                                <td class="align-left" valign="top">
                                    <div class="para"></div>
                                </td>
                                <td class="align-left" valign="top">
                                    <div class="para"></div>
                                </td>
                                <td class="align-left" valign="top">
                                    <div class="para"></div>
                                </td>
                                <td class="align-left" valign="top">
                                    <div class="para"></div>
                                </td>
                                <td class="align-left" valign="top">
                                    <div class="para"></div>
                                </td>
                                <td class="align-left" valign="top">
                                    <div class="para"></div>
                                </td>
                                <td class="align-left" valign="top">
                                    <div class="para"></div>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                    <table class="frame-all">
                        <colgroup>
                            <col class="colnum-1 colname-col1 colwidth-6"></col><col class="colnum-2 colname-col2 colwidth-6"></col><col class="colnum-3 colname-col3 colwidth-6"></col><col class="colnum-4 colname-col4 colwidth-6"></col><col class="colnum-5 colname-col5 colwidth-7"></col><col class="colnum-6 colname-col6 colwidth-7"></col><col class="colnum-7 colname-col7 colwidth-25"></col><col class="colnum-8 colname-col8 colwidth-10"></col><col class="colnum-9 colname-col9 colwidth-15"></col></colgroup>
                        <tbody>
                            <tr>
                                <td colspan="3" align="center" valign="top">
                                    <div class="para">DEPOSIT 10% HARGA RIZAB</div>
                                </td>
                                <td colspan="3" align="center" valign="top">
                                    <div class="para">BAKI 90% HARGA BELIAN</div>
                                </td>
                                <td class="align-left" rowspan="2" valign="top">
                                    <div class="para">TARIKH PEMYATA BAILIF DAN BAUCARDISEDIAKAN</div>
                                </td>
                                <td class="align-left" rowspan="2" valign="top">
                                    <div class="para">TARIKH PENYATA DAN TARIKH BAUCAR DIHANTAR KE BAHAGIAN KEWANGAN</div>
                                </td>
                                <td class="align-left" rowspan="2" valign="top">
                                    <div class="para">TARIK CEK BAYARAN DIKELUARKAN/DIHANTAR KEPADA PENAWAR</div>
                                </td>
                            </tr>
                            <tr>
                                <td class="align-center" valign="top">
                                    <div class="para">Tarikh</div>
                                </td>
                                <td class="align-center" valign="top">
                                    <div class="para">No. Resit</div>
                                </td>
                                <td class="align-center" valign="top">
                                    <div class="para">Jumlah</div>
                                </td>
                                <td class="align-left" valign="top">
                                    <div class="para">Tarikh</div>
                                </td>
                                <td class="align-center" valign="top">
                                    <div class="para">No. Resit</div>
                                </td>
                                <td class="align-center" valign="top">
                                    <div class="para">Jumlah</div>
                                </td>
                                <td class="align-left" valign="top">
                                    <div class="para"></div>
                                </td>
                                <td class="align-left" valign="top">
                                    <div class="para"></div>
                                </td>
                                <td class="align-left" valign="top">
                                    <div class="para"></div>
                                </td>
                            </tr>
                            <tr>
                                <td class="align-left" valign="top">
                                    <div class="para"></div>
                                </td>
                                <td class="align-left" valign="top">
                                    <div class="para"></div>
                                </td>
                                <td class="align-left" valign="top">
                                    <div class="para"></div>
                                </td>
                                <td class="align-left" valign="top">
                                    <div class="para"></div>
                                </td>
                                <td class="align-left" valign="top">
                                    <div class="para"></div>
                                </td>
                                <td class="align-left" valign="top">
                                    <div class="para"></div>
                                </td>
                                <td class="align-left" valign="top">
                                    <div class="para"></div>
                                </td>
                                <td class="align-left" valign="top">
                                    <div class="para"></div>
                                </td>
                                <td class="align-left" valign="top">
                                    <div class="para"></div>
                                </td>
                            </tr>
                        </tbody>
                    </table>
and i'm getting some wrong output format.

Here i'm unable to understand what entry colname="col2" is for and how to render it in my XSLT. please let me know what is the use of this and also please suggest me some CALS Tables XSLT tutorial.

Thanks
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cals Table Colspec - HTML td rangeshram XSLT 2 June 17th, 2013 01:09 AM
Cals table to Html table XSLT ROCXY XSLT 6 July 13th, 2010 11:56 AM
very urgent:cals table to indesign table using xsl franklinclinton XSLT 1 December 16th, 2009 03:48 PM
Empty rows created in Access table ayazhoda Access VBA 7 May 10th, 2007 06:23 AM



All times are GMT -4. The time now is 02:04 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.