xsl-list
[Top] [All Lists]

Count a substring of an attribute in childnodes

2005-03-09 03:45:40
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*" />
</tgroup>

I have tried with

<?xml version="1.0"?>
<xsl:stylesheet
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
        version="1.0">

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

<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>
</xsl:template>

</xsl:stylesheet>

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

What am I doing wrong?

Regards,
Ragulf Pickaxe :-|

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


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--