xsl-list
[Top] [All Lists]

Re: [xsl] Question about table column width in XSLT/XSLFO

2006-10-17 09:53:44
At 2006-10-17 09:20 -0700, ms wrote:
Well, I am a little confused. Please bear with me as I
try to explain.

My XML does not have "colnum" as an attrinute to 'colspec".

Fine ... my code suggestion to you did not include any use of "colnum".

It only has "colname",

Yes, your original post showed this.

and the "entry" tag
has the "namest" and "namend". The "colname" tag has
names of the columns like "c1", "c2" etc. So how the
XML for entry will have
<entry namest="c1" namend="c9">

Right. That is typical of OASIS/CALS tables. Many of us have seen a lot of this.

How do you achieve column span using these column
names instead of column numbers in xslt?

What part of my example did not work for you?

Thank you for all your patience and help.

You are welcome, but it seems you did not even try using my previous answer to this same question. I outlined an untested example of the kind of code you need to answer your question. At which part of using my example did you have problems?

Below is the same example, but polished up with your actual test data from your earlier post to illustrate what I gave you in my last post. This code is actually tested. It takes more time to volunteer a tested working solution than to answer inquiries of the general direction to take when solving a problem.

The code below determines the number of columns being spanned by the namest= and nameend= attributes when the current node is <entry>, and assigns the value to the colspan= attribute.

What part of the example in my earlier email, as modified below, didn't work for you?

. . . . . . . . . . . . Ken

T:\ftemp>type meenakshi.xml
<?xml version="1.0" encoding="US-ASCII"?>
<table tocentry="Y">
<tgroup align="left" charoff="50" cols="4">
<colspec colname="c1" colwidth="1.50in">
 </colspec>
<colspec colname="c2" colwidth="2.0in">
 </colspec>
<colspec colname="c3" colwidth="3.0in">
 </colspec>
        <colspec colname="c4" colwidth="1in">
 </colspec>
        <tbody valign="top">
          <row>
            <entry namest="c1" nameend="c3"/>
            <entry namest="c1" nameend="c2"/>
            <entry namest="c2" nameend="c3"/>
          </row>
        </tbody>
      </tgroup>
    </table>
T:\ftemp>type meenakshi.xsl
<?xml version="1.0" encoding="US-ASCII"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
                version="1.0">

<xsl:output indent="yes"/>

<xsl:template match="/">
  <xsl:for-each select="//entry">
    <test colspan="{
            
count(ancestor::table[1]/*/colspec[(_at_)colname=current()/@nameend]/
                  preceding-sibling::colspec ) -
            count(ancestor::table[1]/*/colspec[(_at_)colname=current()/@namest]/
                  preceding-sibling::colspec )
                   + 1 }"/>
  </xsl:for-each>
</xsl:template>

</xsl:stylesheet>

T:\ftemp>xslt meenakshi.xml meenakshi.xsl con
<?xml version="1.0" encoding="utf-8"?>
<test colspan="3"/>
<test colspan="2"/>
<test colspan="2"/>
T:\ftemp>

--
UBL/XSLT/XSL-FO training: Allerød/Vårø Denmark 2006-11-13,17,20/24
UBL International 2006  2006-11-13/17 http://www.ublconference.com
World-wide corporate, govt. & user group UBL, XSL, & XML training.
G. Ken Holman                 mailto:gkholman(_at_)CraneSoftwrights(_dot_)com
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/s/
Box 266, Kars, Ontario CANADA K0A-2E0    +1(613)489-0999 (F:-0995)
Male Cancer Awareness Aug'05  http://www.CraneSoftwrights.com/s/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--