Re: [xsl] Omnimark vs. XSL (Saxon) Challenge

Subject: Re: [xsl] Omnimark vs. XSL (Saxon) Challenge
From: bry@xxxxxxxxxx
Date: Tue, 16 Mar 2004 21:26:41 CET
well I have a lot of stuff in a language not 
xslt to clear up right now, and saxon is not 
running to good on my system at the moment 
so I can't sit and play with it but some 
observations:
-<xsl:variable name =" cols " >
-<xsl:variable name =" first-row " >
-<xsl:for-each select =" $root//row
[1]/entry " >
-<entry>
-<xsl:attribute name =" colspan " >
-<xsl:choose>
-<xsl:when test =" @colspan > 1 " >
<xsl:value-of select =" @colspan " />
 </xsl:when>
-<xsl:otherwise>
<xsl:value-of select =" 1 " />
 </xsl:otherwise>
 </xsl:choose>
 </xsl:attribute>
 </entry>
 </xsl:for-each>
 </xsl:variable>
<xsl:value-of select =" sum($first-
row/entry/@colspan) " />
 </xsl:variable>
just reading through your input xml I get 
the feeling that what you actually mean is 
that if there isn't a colspan then the 
colspan= 1, is that correct. So I figure 
that in that case checking if @colspan is 
greater than 1 is redundant, one should just 
check if @colspan exists.

However in that case isn't this the same as 
what you're looking for:

<xsl:value-of select="sum($root//row
[1]/entry/@colspan) + count($root//row
[1]/entry[not(@colspan)])"/>


I really don't know what the random-nodes.r 
and c are for, not having much time here but
<xsl:variable name =" random-nodes-r " 
select =" document('')//* " />
<xsl:variable name =" random-nodes-c " 
select =" document('')//* " />

is redundant, since variables in xslt are 
constants you only need declare one of these 
and then use that one all the time. 

this also is using up a lot of processing:

<xsl:for-each select =" $random-nodes-r
[position() <= $rows] " >
<xsl:variable name =" row-num " select =" 
position() " />
-<xsl:for-each select =" $random-nodes-c
[position() <= $cols] " >
<xsl:variable name =" col-num " select =" 
position() " />
<cell row =" {$row-num} " col =" {$col-
num} " />
 </xsl:for-each>
 </xsl:for-each>

since you're going over the essentially same 
tree twice.

under col-widths you again declare a new 
variable:
<xsl:variable name =" random-nodes " select 
=" document('')//* " />

if you're going to be accessing this so 
often probably want to do it as a global 
variable, and not declare it multiple times 
as  a variable within a global variable.


so those are a few quick points I noticed.
> Dear experts,
> 
> Recently I was quite unimpressed by the 
presentation of an Omnimark script requiring 
32
seconds to make what seemed like a little 
change to a 2000 cells table. I said, this 
would
be possible with XSL as well, and suddenly I 
found myself challenged.
> 
> After some hours I have a working solution 
but it is so slow... I hope I have missed
something important with my method and now I 
am seeking assistance.
> 
> The task seemed simple at first:
> 
> HTML tables usually have width attributes 
for each cell. CALS and some other table 
models
require all column widths to be specified at 
the top level, e.g. as an attribute of the
table element. 
> 
> Input table:
> 
> <table>
>   <tbody>
>     <row>
>       <entry colspan="2" rowspan="2" 
width="70%">I</entry>
>       <entry colspan="2" 
width="30%">II</entry>
>     </row>
>     ...
>   </tbody>
> </table>
> 
> Desired output:
> 
> <table width="48mm 36mm 24mm 12mm">
>   <tbody>
>     <row>
>       <entry colspan="2" 
rowspan="2">I</entry>
>       <entry colspan="2">II</entry>
>     </row>
>     ...
>   </tbody>
> </table>
> 
> The main problem is the use of colspan and 
rowspan, which makes it hard for any cell to
know to which column it belongs. One has to 
render the table from start to finish to 
learn
that for each cell.
> 
> I read about Michael Kay's "Knight's Tour 
Stylesheet" and created a very recursive 
similar
thing. I recursively loop through all rows, 
through all cells, within spanned cells
through all rowspans and then through all 
colspans.
> 
> I would very much appreciate any comments 
and will gladly summarize.
> 
> Please find links to the stylesheet and 
sample files at 
> 
> http://cap-studio.de/test/challenge.html
> 
> Thanks a lot,
> 
> - Michael
> -- 
> 
_____________________________________________
___________
> Michael Müller-Hillebrand, cap studio, 
Erlangen, Germany
> http://cap-studio.de/en/
> Increase Knowledge Worker's Efficiency 
using
> FrameMaker, XML/XSL, FrameScript, WebWorks 
Publisher,...
> 
>  XSL-List info and archive:  
http://www.mulberrytech.com/xsl/xsl-list
> 
> 






 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread