RE: [xsl] Calculating column widths

Subject: RE: [xsl] Calculating column widths
From: "Michael Kay" <mhkay@xxxxxxxxxxxx>
Date: Wed, 16 May 2001 00:27:11 +0100
> My question:
> how can I do this calculation in one parse?
> The sum() function requires a node-set
> and numeric values to function properly,
> and I have been unable to do the stripping
> and the calculation in one template.

You could do the summation "by hand" in a recursive template, rather than
using the sum() function, but I'm not sure I'd recommend this. It rather
depends what you're trying to achieve.

You can of course do a two-pass transformation using a result-tree-fragment
for the intermediate results and using RTF-to-nodeset conversion for the
second pass.

Alternatively, Saxon has the extension function saxon:sum(node-set,
expression) which allows you to sum over the result of an XPath expression
applied to the context node. This expression can also contain a call on a
saxon:function() defined in the stylesheet. (But you could strip off the
units part of your numbers using a standard expression based on translate(),
converting all alpha characters to spaces).

I'm not sure any of these is a real improvement on what you're currently

Mike Kay

 XSL-List info and archive:

Current Thread