Subject: RE: [xsl] xslt 2.0 challenge From: "Andrew Welch" <AWelch@xxxxxxxxxxxxxxx> Date: Thu, 8 Apr 2004 13:35:13 +0100 |
Ok here's my attempt. This is as much about learning 2.0 as find a solution, so all comments/criticisms welcome, including code formatting suggestions (that's if the formatting makes it though the mailer). <xsl:template match="/"> <xsl:variable name="spanspec" select="/table/tgroup/spanspec"/> <!-- constucts a sequence of the two colspecs, note the 'as' --> <xsl:variable name="first" as="element()+"> <xsl:sequence select="/table//colspec[(preceding-sibling::colspan[@colname = $spanspec/@namest] and following-sibling::colspan[@colname = $spanspec/@nameend]) or @colname = $spanspec/@namest or @colname = $spanspec/@nameend]"/> </xsl:variable> <!-- sums the columns specified by the start and end column by the total number of columns, and then formats it to two decimal places and concats on a percentage symbol --> <xsl:value-of select="concat( string( format-number( (sum(for $x in $first/@colwidth return number(translate($x,'m',''))) div sum(for $x in $first/../colspec/@colwidth return number(translate($x,'m','')))) * 100, '00.00') ) ,'%')"/> </xsl:template> One point of interest here is the the $first variable must be declared as 'element()+' so that we can access it's siblings later on (thanks to Roger L. Costello post on the Saxon list for that). This should be faster and less memory hungry than building three temporary trees, I will get around to testing it out soon. cheers andrew
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] xslt 2.0 challenge, Jeni Tennison | Thread | Re: [xsl] xslt 2.0 challenge, David Carlisle |
Re: [xsl] Can I change variable con, David Carlisle | Date | Re: [xsl] Can I change variable con, Vikram Barate |
Month |