Re: tables or grids ?

Subject: Re: tables or grids ?
From: shennessy@xxxxxxxxxx
Date: Fri, 07 Aug 98 10:49:31 -0800

Date: Friday, August 07, 1998 3:11 PM
David wrote:

>..I don't see how I can
>calculate the required amount of spacing given that I can't measure
>anything in dsssl.



Please allow me to share with you what I have done with tables.  Please
correct where I am in error.
A DSSSL gremmie learning trial and error fashion and now in the thick of an
SGML to XYWrite table transform ( don't ask..).  It looks as if the borders,
alignment, and spanning of tables will need to be done explicitly by our
style-sheet.  I am a novice schemer who is contemplating how to generate
an associated list in order to calculate the ceiling ( max cell width) of
each of the colums in a table.
This ceiling list will then be referenced for overall table width and
bordering as well as each cell/entry alignment for ASCII output,
mono-spaced, DOS application.

I found the following two descriptions of the CALS table model Document
Type Definition helpful in my attempt to decipher our client's own deviant
table DTD and the conventions used for table markup.
http://www.sil.org/sgml/tr9502.html
http://www.oasis-open.org/html/a502.htm

The language concerning colwidth attribute use of "N*" requires a
proportional caclulation
of each column against the sum of all columns.  I especially liked the "If
the table fixed widths take up too much of the indicated table width,then it
is up to the output system to resolve the conflict." part...more work for
me.

So for our two column table with the following markup..
<colspec colname="col1" colwidth="200*"><colspec colname="col2"
colwidth="195*">
We get..
P1 = proportion of col1 = (200 / (200 + 195)) = 0.506329...
P2 = proportion of col2 = (195/ (200 + 195)) =  0.493670...
together with the table dispwid attributes we should be able to calculate
the format of the
table on the fly..  or at least that is what I think..

Here is what I have so far..the code is instrumented with literals for
debug/development..
Editor does not help me track the parens so the coding style reflects..

W. Sean Hennessy

<!--BEGIN COMMENT BLOCK END -->
(define %gColPrefix% "col")
(define %gTblBdrChr% "Ä" )            ;;char used as table border
(define %gnMaxLineWidth% 78 )    ;; Number of chars allowed
(define %gnLRBrder% 4 )                ;;

;======================================
<!--
;;[work in progress]
;; pull the data from the ptxt child and do the alignment based
;; on parent attribute info which has ancestors...
;;<tgroup cols="2" colsep="1" rowsep="1">
;;<colspec colname="col1" colwidth="200*"><colspec colname="col2"
colwidth="195*">
;;<thead><row><entry valign="top"
align="left"><ptxt>Application</ptxt></entry>
;;<entry valign="top"
align="left"><ptxt>Location</ptxt></entry></row></thead>
;;<tbody><row><entry valign="top" align="left"><ptxt>ABS Control Unit</ptxt>
;;</entry><entry valign="top" align="left"><ptxt>Behind Rear Seat
Back</ptxt>
;;</entry></row>
;;</tbody></tgroup></table>
;;
-->
;======================================
(element (ROW ENTRY)
 ( let* (
  ( atAlign (attribute-string "ALIGN" (current-node)))
  ( theTxt (data (current-node )))
  ( tnTxtLngth (string-length theTxt))
  ( tnInstance (child-number (current-node)) ) ;; this entry's column #
  ( tstrTheInst (number->string tnInstance ))
  ( tTgtAttr (string-append %gColPrefix% tstrTheInst))
  ( colspec (find-colspec-by-number tnInstance))  ;; from dbtable.dsl
  ( tstrWidth (colspec-colwidth colspec) )   ;; from dbtable.dsl
  ( tnNumCols (string->number (attribute-string "COLS" (ancestor
"TGROUP"))))
  ( tnDspWidth  ( - %gnMaxLineWidth%  (+ %gnLRBrder% ( - tnNumCols 1))  ))
 );eoletgroup
 (make table-cell
;;  cell-row-alignment: atAlign
;;  cell-before-column-border: #t

  (literal (number->string tnDspWidth))
    (literal "[")
  (literal tTgtAttr) ;; which column ?
    (literal "= ")
    (literal tstrWidth)
    (literal "]")
  (literal (number->string tnTxtLngth)) ;; length of text within this cell
  (literal theTxt)
;;  (process-children-trim)     ;;
 );eomtblcell
 );eolet
)
<!--BEGIN COMMENT BLOCK END -->







 DSSSList info and archive:  http://www.mulberrytech.com/dsssl/dssslist


Current Thread
  • tables or grids ?
    • David Carlisle - from mail1.ability.netby web4-1.ability.net (8.8.5/8.6.12) with ESMTP id KAA05895Fri, 7 Aug 1998 10:08:27 -0400 (EDT)
      • <Possible follow-ups>
      • shennessy - from mail1.ability.netby web4-1.ability.net (8.8.5/8.6.12) with ESMTP id NAA18425Fri, 7 Aug 1998 13:55:29 -0400 (EDT) <=
        • David Carlisle - from mail1.ability.netby web4-1.ability.net (8.8.5/8.6.12) with ESMTP id GAA29906Mon, 10 Aug 1998 06:24:15 -0400 (EDT)