Re: CALS Tables (was: RE: [xsl] XSL(check attribute exists in the parent node and get value for another attribute in the same node))

Subject: Re: CALS Tables (was: RE: [xsl] XSL(check attribute exists in the parent node and get value for another attribute in the same node))
From: smiley <smile_gk@xxxxxxxxx>
Date: Wed, 13 Aug 2003 18:49:48 -0700 (PDT)
hi andrew,

If you have a css which has t,bl & r defined, can you
please copy it for me.

Thanks,
--- Andrew Welch <AWelch@xxxxxxxxxxxxxxx> wrote:
> 
> For anyone working with CALS tables, here is a
> stylesheet I wrote a while back to display them.  I
> think it covers all of the variations that CALS
> allows (which is a lot).
> 
> It will produce a table 300px high, with a 'fixed
> header' so that the body scrolls while the head is
> fixed.
> 
> It just requires that 't' 'b' 'l' and 'r' are
> defined in your CSS as 1px solid black borders.
> 
> Im confident that it can take whatever gets thrown
> at it, but if anyone can improve it (and repost :)
> or find a fault, please let me know.
> 
> cheers
> andrew
> 
> (Ive just removed some things specific to my
> company, so if some of the html structure looks
> slightly off, its probably because Ive just deleted
> some it)
> 
> 
> <xsl:stylesheet
> 	xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
>     xmlns:exsl="http://exslt.org/common";
> 	extension-element-prefixes="exsl"
> 	version="1.0">
> 
> <xsl:param name="print" select="'no'"/>
> <xsl:param name="printWidth" select="0"/>
> 
> <!-- tests for aircrew dm, we dont use scroll bars
> on aircrew dm's-->
> <xsl:variable name="acrw"
> select="boolean(/dmodule/content/acrw)"/>
> 
> <xsl:variable name="colspecs-firstPass-rtf">
>   <xsl:for-each select="//table">
>     <table id="{generate-id()}">
>       <xsl:for-each select="tgroup">
>         <tgroup id="{generate-id()}">
>           <xsl:for-each select=".//colspec">
>             <col id="{generate-id()}"
> colname="{@colname}"
> number="{count(preceding-sibling::colspec|.)}"
> width="{translate(@colwidth,'inm*','')}"
> align="{@align}">
>               <xsl:attribute name="inHead">
>                 <xsl:choose>
>                   <xsl:when
> test="parent::thead">yes</xsl:when>
>                   <xsl:otherwise>no</xsl:otherwise>
>                 </xsl:choose>
>               </xsl:attribute>
>             </col>
>           </xsl:for-each>
>           <xsl:for-each select="spanspec">
>             <spanspec id="{generate-id()}"
> spanname="{@spanname}" namest="{@namest}"
> nameend="{@nameend}" align="{@align}"/>
>           </xsl:for-each>
>         </tgroup>
>       </xsl:for-each>
>     </table>
>   </xsl:for-each>
> </xsl:variable>
> 
> <xsl:variable name="colspecs-firstPass"
> select="exsl:node-set($colspecs-firstPass-rtf)"/>
> 
> <xsl:variable name="colspecs-rtf">
>   <xsl:for-each select="$colspecs-firstPass">
>     <xsl:for-each select="table">
>       <table id="{@id}">
>         <xsl:for-each select="tgroup">
>           <tgroup id="{@id}">
>             <xsl:variable name="totalGroupWidth"
> select="sum(col[@inHead = 'no']/@width)"/>
>             <xsl:variable name="totalHeadWidth"
> select="sum(col[@inHead = 'yes']/@width)"/>
>             <xsl:for-each select="col">
>               <col id="{@id}" colname="{@colname}"
> number="{@number}" align="{@align}"
> inHead="{@inHead}">
>                 <xsl:attribute name="width">
>                   <xsl:choose>
>                     <xsl:when test="@inHead = 'no'">
>                       <xsl:value-of select="@width
> div $totalGroupWidth * 100"/>
>                     </xsl:when>
>                     <xsl:otherwise>
>                       <xsl:value-of select="@width
> div $totalHeadWidth * 100"/>
>                     </xsl:otherwise>
>                   </xsl:choose>
>                 </xsl:attribute>
>               </col>
>             </xsl:for-each>
>             <xsl:for-each select="spanspec">
>               <xsl:copy-of select="."/>
>             </xsl:for-each>
>           </tgroup>
>         </xsl:for-each>
>       </table>
>     </xsl:for-each>
>   </xsl:for-each>
> </xsl:variable>
> 
> <xsl:variable name="colspecs"
> select="exsl:node-set($colspecs-rtf)"/>
> 
> <xsl:variable name="spanspecs-rtf">
>   <xsl:for-each select="$colspecs">
>     <xsl:for-each select="table/tgroup">
>       <xsl:variable name="tgroupId" select="@id"/>
>       <xsl:for-each select="spanspec">
>         <col id="{@id}" spanname="{@spanname}">
>           <xsl:attribute name="colspan">
>             <xsl:value-of select="1 +
> preceding-sibling::col[@colname =
> current()/@nameend]/@number -
> preceding-sibling::col[@colname =
> current()/@namest]/@number"/>
>           </xsl:attribute>
>           <xsl:attribute name="width">
>             <xsl:call-template
> name="calculateWidth">
>               <xsl:with-param name="tgroupId"
> select="$tgroupId"/>
>               <xsl:with-param name="startCol"
> select="preceding-sibling::col[@colname =
> current()/@namest]/@number"/>
>               <xsl:with-param name="endCol"
> select="preceding-sibling::col[@colname =
> current()/@nameend]/@number"/>
>             </xsl:call-template>
>           </xsl:attribute>
>           <xsl:attribute name="align">
>             <xsl:choose>
>               <xsl:when
> test="string-length(@align)"><xsl:value-of
> select="@align"/></xsl:when>
>               <xsl:otherwise><xsl:value-of
> select="preceding-sibling::col[@colname =
> current()/@nameend]/@align"/></xsl:otherwise>
>             </xsl:choose>
>           </xsl:attribute>
>         </col>
>       </xsl:for-each>
>     </xsl:for-each>
>   </xsl:for-each>
> </xsl:variable>
> 
> <xsl:variable name="spanspecs"
> select="exsl:node-set($spanspecs-rtf)"/>
> 
> <xsl:template name="calculateWidth">
>   <xsl:param name="tgroupId" select="0"/>
>   <xsl:param name="startCol" select="0"/>
>   <xsl:param name="endCol" select="0"/>
>   <xsl:param name="totalWidth" select="0"/>
>   <xsl:choose>
>     <xsl:when test="$startCol &lt;= $endCol">
>       <xsl:call-template name="calculateWidth">
>         <xsl:with-param name="tgroupId"
> select="$tgroupId"/>
>         <xsl:with-param name="startCol"
> select="$startCol + 1"/>
>         <xsl:with-param name="endCol"
> select="$endCol"/>
>         <xsl:with-param name="totalWidth">
>           <xsl:for-each select="$colspecs">
>             <xsl:for-each select="table/tgroup[@id =
> $tgroupId]">
>               <xsl:value-of select="col[@number =
> $startCol]/@width + $totalWidth"/>
>             </xsl:for-each>
>           </xsl:for-each>
>         </xsl:with-param>
>       </xsl:call-template>
>     </xsl:when>
>     <xsl:otherwise>
>       <xsl:value-of select="$totalWidth"/>
>     </xsl:otherwise>
>   </xsl:choose>
> </xsl:template>
> 
> <xsl:template name="getBorders">
>   <xsl:param name="frame" select="''"/>
>   <xsl:choose>
>     <xsl:when test="$frame = 'ALL'">t b l
> r</xsl:when>
>     <xsl:when test="$frame = 'TOP'">t</xsl:when>
>     <xsl:when test="$frame = 'TOPBOT'">t
> b</xsl:when>
>     <xsl:when test="$frame = 'BOTTOM'">b</xsl:when>
>     <xsl:when test="$frame = 'SIDES'">l r</xsl:when>
> 
=== message truncated ===


__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

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


Current Thread