[xsl] Count a substring of an attribute in childnodes

Subject: [xsl] Count a substring of an attribute in childnodes
From: "Ragulf Pickaxe" <jawxml@xxxxxxxxxxx>
Date: Wed, 09 Mar 2005 10:45:40 +0000
Hi all,

I am trying to transform CALS tables to HTML in one pass.

To this, I need the total number of all colwidth attributes that contains a *.

The following XML snippet should give me a total of 600.

<?xml version="1.0"?>
<tgroup cols="3" colsep="0" rowsep="0" align="left">
<colspec colname="1" colwidth="100*" />
<colspec colname="2" colwidth="200*" />
<colspec colname="3" colwidth="300*" />

I have tried with

<?xml version="1.0"?>

<xsl:template match="/">
 <xsl:apply-templates select="tgroup"/>

<xsl:template match="tgroup">
<xsl:variable name="total-colwidth" select="'count(number(colspec[contains(@colwidth,'*')]/substring-before(@colwidth,'*')))'"/>
<Output><xsl:value-of select="$total-colwidth"/></Output>


But this one gives me <Output>NaN</Output>

What am I doing wrong?

Ragulf Pickaxe :-|

Express yourself instantly with MSN Messenger! Download today it's FREE! http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/

Current Thread