Forum OpenACS Q&A: Re: List builder and column widths of generated tables

Collapse
Posted by Andrei Popov on

No, what I want is to generate a page that can then be picked up by XSLT/FO processor to generate a PDF. I have (had, since migration) it working on 4.6.3, but it was just a hand-written ADP page that simply had a <colspec> tag.

Problem is that FOP cannot do automatic/proportional table layout -- it needs fixed.

I've started trying to add a -colspec {list} parameter to template::list::create, but am running on varname:rowcount problems. Tcl code I added to list-proc.tcl goes thusly:

    # setup colspec param
    set colspec:rowcount 0
    template::multirow create colspec width
    foreach width $list_properties(colspec) {
        template::multirow  append colspec width
    }
Array list_properties also has an element (list) added. On acs-templating/resource/table.adp side I added:
  <if @list_properties.colspec@ not nil>
    <colspec>
    <multiple name="colspec">
      <col @colspec.width@ />
    </multiple>
    </colspec>
  </if>

Calling page:

template::list::create -name bugs -multirow bugs \
    -key bug_number \
    -elements $elements \
    -filters $filters \
    -html {cols 6} \
    -colspec {10 10 10 10 10 10}

With this I get:

can't read "colspec:rowcount": no such variable
    while executing
"for { set __d39_i 1 } { $__d39_i <= ${colspec:rowcount}  } { incr __d39_i } {
    upvar 0 colspec:$__d39_i colspec
  
append __adp_output "
      <col..."
    invoked from within
"if {! ([template::util::is_nil list_properties(colspec)])} {
append __adp_output "
    <colspec>
    "


  if {[info exists colspec]} {
      upvar 0 ..."

If I add -local switch and then start playing with -ulevel and template::multirow upvar I start getting colspec:rowcount already defined.

This is just a bit over my Tcl skills :(....

Collapse
Posted by Jeff Davis on
template::multirow create colspec width

should create the colspec:rowcount variable so my guess is that this is not being called that or the template is not being evaled at adp_level. You could add a <%= [info locals] %> in place of your multiple loop just to see what variables are in fact defined.

also this:

template::multirow  append colspec width
should be:
template::multirow  append colspec $width
Collapse
Posted by Andrei Popov on
colspec:rowcount is indeed missing in <%= [info locals] %> output

I've tried to change as follows:

set colspec:rowcount 0
template::multirow create colspec width
foreach width $list_properties(colspec) {
    template::multirow append colspec $width
}
template::multirow -local -ulevel [expr $ulevel + 1] upvar colspec

but result is the same/similar: if I leave set colspec:rowcount I get colspec:rowcount already defined, if I comment it out, I get colspec:rowcount no such variable.

Playing with differnt values of -ulevel does not help either...

Collapse
Posted by Jeff Davis on
Are you sure the code is really being executed? You might want to put an ns_log statment in there. Also, an alternative (since it seems the list_properties.colspec var does wind it's way through) is to use the <list> tag to generate the colspec.

Out of curiousity, what are you using to xform html to fo (is it some standard xsl or something you wrote yourself)?

I have been using docbook-xsl and FOP to produce PDFs and have been ok with the output although I see a lot of shortcomings with FOP for realistic sized documents.

Collapse
Posted by Andrei Popov on
Yeah, code is being executed all right.  I had ns_log in there and -colspec gets read and if you call template::multirow size it returns 6 -- the number of rows in the created multirow!

I am using XHTML2FO XSL stylesheet as picked up from Antenna House website here: http://www.antennahouse.com/XSLsample/XSLsample.htm

Works very well.  What I do is a bit of a hack, really: I fetch (rather wget) the page, pass it through tidy to make sure that all that has to be quoted is, then apply XSL transformation using xsltproc.  Once .fo is generated I use FOP to produce a .pdf out of it.