[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: Woody <woody@xxxxxxxxxxxxxx>
Date: Mon, 14 Apr 2003 21:34:48 +0100
xsl node fragments
At 13:57 14/04/2003 -0400, you wrote:
From: TSchutzerWeissmann@xxxxxxxxxxxxxxxx


>
> <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"/>
[...]
> Problem here is that I need to change the COLWIDTH into
> percentages to
> render out to the table.

if you want to avoid using node-set() then you will need a recursive
template to get you the total column width from which to calculate the
percentages.

To get rid of "in" etc. you can use
translate(@COLWIDTH,"abcdefghijklmnopqrstuvwxyz","") to get just the
numerical value.

  <xsl:template name="get_total_width">
    <xsl:param name="nodes" select="/.."/>
    <xsl:param name="sub_total" select="0"/>
    <xsl:variable name="width"
      select="number(
              translate($nodes/@COLWIDTH,
              'abcdefghijklmnopqrstuvwxyz',
      '')
      )"/>
      <xsl:choose>
        <xsl:when test="count($nodes) &gt; 1">
           <xsl:call-template name="get_total_width">
            <xsl:with-param name="nodes" select="$nodes[position() != 1]"/>
              <xsl:with-param name="sub_total" select="$sub_total +
$width"/>
            </xsl:call-template>
          </xsl:when>
          <xsl:otherwise>
            <xsl:value-of select="$sub_total + $width"/>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:template>

then you can call it to get the total for the table you're looking at:


<xsl:variable name="total_width"> <xsl:call-template name="get_total_width"> <xsl:with-param name="nodes" select="TGROUP/COLSPEC[@COLNUM]"/> </xsl:call-template> </xsl:variable>


and as long as the variable's in scope, use it to calculate the percentage.

thanks! I will give that a try tomorrow.


Thanks also to the others that replied. Unfortunately I can't do the two pass thing either as the data on the PC is on a DVD whilst the data on the mac is on the disk. Also both machines have an entirely different disk structure so the problem with external files is that the location of them are different.

Oh, the joys of cross platform standardised languages :)

Woody






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



Current Thread

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.