[xsl] using node fragments

Subject: [xsl] using node fragments
From: Woody <woody@xxxxxxxxxxxxxx>
Date: Mon, 14 Apr 2003 15:36:37 +0100
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.

I started with:

<xsl:variable name="sizes">
<xsl:for-each select="ancestor::TGROUP/COLSPEC[@COLNUM]/@COLWIDTH">
<xsl:sort select="@COLNUM" order="ascending" data-type="number"/>
<xsl:variable name="str" select="."/>
<xsl:choose>
<xsl:when test="contains($str,'in')"><xsl:value-of select="substring($str,1,string-length($str)-2)"/></xsl:when>
<xsl:otherwise><xsl:value-of select="$str"/></xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:variable>


which gets a tree fragment of the sizes which I was then intending to add up and convert to a percentage but hit the problem that it is a tree fragment which I can't do anything useful with.

As far as I can see I have the options of using javascript or node-set() to be able to do anything with these values, both of which are not xslt 1.0 (which is what I was aiming for).
As I want to run this on two separate xsl processors (msxml on the PC and sablotron on the mac) am I stuck with having to have two separate stylesheets for use in this?



Woody



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



Current Thread