[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: using node fragments

Subject: RE: using node fragments
From: "Passin, Tom" <tpassin@xxxxxxxxxxxx>
Date: Mon, 14 Apr 2003 12:46:16 -0400
RE:  using node fragments
[ Woody [mailto:woody@xxxxxxxxxxxxxx] ]
> 
> I have this section of an xml file that needs to be rendered 
> to a table
> 
> <TGROUP>
>    <COLSPEC COLNUM="1" COLNAME="1" COLWIDTH="0.713in"/>
>    <COLSPEC COLNUM="2" COLNAME="2" COLWIDTH="1.179in"/>
>    <COLSPEC COLNUM="3" COLNAME="3" COLWIDTH="1.272in"/>
>    <COLSPEC COLNUM="4" COLNAME="4" COLWIDTH="3.283in"/>
>    <THEAD>
>      <ROW>
>        <ENTRY COLNAME="1">Item</ENTRY>
>        <ENTRY COLNAME="2">Control</ENTRY>
>        <ENTRY COLNAME="3">Selection</ENTRY>
>        <ENTRY COLNAME="4">Function</ENTRY>
>          </ROW>
>          </THEAD>
>                  ... lots of rows follow here
> 
> Problem here is that I need to change the COLWIDTH into 
> percentages to 
> render out to the table.
> 

Other replies to your question have pointed out that you need to either
use a node-set() extension or do the transform in two passes.  However,
if you could influence the source xml to get rid of the "in" after the
value of the COLWIDTH, then you could avoid both node-set() and two
passes. If there is still some need for specifying "in", it could be
done by using another attribute instead.

Here is a sketch of how the stylesheet could work.  I have omitted
sorting the columns and other refinements but you can add them if
necessary.

<xsl:template match="/root">
<html>
.... Other html stuff here ...
<table>
   <xsl:call-template name='do-head'/>
... invoke template for row data here ...
</table>
</html>
</xsl:template>

<xsl:template name='do-head'>
   <xsl:variable name='cols' select='TGROUP/COLSPEC'/>
      <xsl:variable name='total-width' select='sum($cols/@COLWIDTH)'/>
         <tr>
            <xsl:for-each select='$cols'>
               <xsl:variable name='width' select='100*@COLWIDTH div
$total-width'/>
                <th width='{$width}%'><xsl:value-of
select='@COLNAME'/></th>
            </xsl:for-each>
          </tr>
</xsl:template>

Cheers,

Tom P

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


Current Thread
  • using node fragments
    • Woody - Mon, 14 Apr 2003 10:29:45 -0400 (EDT)
      • <Possible follow-ups>
      • Andrew Welch - Mon, 14 Apr 2003 11:39:08 -0400 (EDT)
      • TSchutzerWeissmann - Mon, 14 Apr 2003 11:59:50 -0400 (EDT)
      • Passin, Tom - Mon, 14 Apr 2003 12:42:12 -0400 (EDT) <=
      • Woody - Mon, 14 Apr 2003 16:15:34 -0400 (EDT)
      • Woody - Mon, 14 Apr 2003 16:27:53 -0400 (EDT)

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.