Link to home
Start Free TrialLog in
Avatar of Stazzie
Stazzie

asked on

summing values of column widths

I've got cals tables in xml and am transforming to HTML.
I need to add the column widths of the column numbers indicated in the namest and namend attributes of an entry element. So, if a column spans over col1 to col4  of an 8 column table, I want the sum total of all the widths from col1 to col4, which I would find in the colspec element preceding the entry. How would I do that in xslt? I'm not sure how I can limit the sum to only add columns 1, 2,3 and 4 of the table containing 8 columns.

I am using xslt 1.0
Avatar of Gertone (Geert Bormans)
Gertone (Geert Bormans)
Flag of Belgium image

Hi Stazzie,

an other approach could be to define the width for each column, regardless spanning in the colgroup/col element
that is an approach very similar to how cals deals with column definitions.
Then the width of each column is set correctly at the start of the table,
and all you need to do then is setting the colspan correctly based on name-start and name-end attribute of your cell
if your spanning is more than one the browser will automatically set the width right
This way you don't need to take the pixel size differences caused by the sum versus the browser calculation into account

you could calculate the spanning by iterating over the colspec elements staring with the one named as in namest and ending recursion when you hit the colspec named as in nameend

The very same way you could sum however if you really want to

For making things easier you could do this in two steps (first step listing col references explicitely in an extra attribute)

Cals tables are flexible. So I would like you to post an example if you want some code to get this done
Avatar of Stazzie
Stazzie

ASKER

<table outputclass="fin-dec" id="e13402-tbl15" rowsep="0" colsep="0">
<tgroup cols="7">
<colspec colnum="1" colname="c1" colwidth="255.36px" align="left"/>
<colspec colnum="2" colname="c2" colwidth="74.48px"/>
<colspec colnum="3" colname="c3" colwidth="74.48px"/>
<colspec colnum="4" colname="c4" colwidth="74.48px"/>
<colspec colnum="5" colname="c5" colwidth="74.48px"/>
<colspec colnum="6" colname="c6" colwidth="74.48px"/>
<colspec colnum="7" colname="c7" colwidth="74.48px"/>
<tbody>
<row rowsep="1" valign="bottom">
<entry colname="c1" namest="c1" nameend="c5" outputclass="shade" rowsep="1" fv="1" in="4q">Charges
we deduct from your account value at the time you request certain
transactions</entry>
</row>
</tbody>
</tgroup>
</table>

The above is the code for a table - the entry is spanning columns c1 to c5.  I want to  add up the values of the column widths for colums c1 to c5 so I can use that as the width of a spanned column. There are mulitiple tables in the document and most of them include spans, but the spans cannot be anticipated, so I have to set a condition that basically says that if I've got a span, calculate the total width of the span based on the column widths that are defined in the colspec element at the top of the table.

Thank you for your help!
ASKER CERTIFIED SOLUTION
Avatar of Gertone (Geert Bormans)
Gertone (Geert Bormans)
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Stazzie

ASKER

Thank you Gertone - I will integrate this into our current xslt and let you know how it turns out. It looks like it's going to do the job. Many thanks for your help and attention!
recommendation:
accept my answer: http:#a34920504
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.