Re: n squared behavior with XT for 'preceding' tests?

Subject: Re: n squared behavior with XT for 'preceding' tests?
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Thu, 22 Jul 1999 18:24:16 -0400
At 99/07/22 09:30 +0000, Sebastian Rahtz wrote:
>David Carlisle writes:
> > I less wisely did:
>thank goodness you don't need any sleep, is all I can say. But I am
>very happy to see the result, even if I am noty sure entirely why it
>works... perhaps we need the Holman Annotation.


I can't always take the time to do this, but I always enjoy learning from

The annotated version is below.

I hope this helps.

................ Ken

T:\FTEMP>type test.xml



T:\FTEMP>type test.xsl
<!--XSL stylesheet by David Carlisle; annotations by G. Ken Holman-->
<xsl:stylesheet xmlns:xsl="";

                    <!--for everything that isn't special, just copy it-->
<xsl:template match="*" >
       <!--this element needs to be coagulated with following adjacents-->
<xsl:template match="mi">                    
         <!--if this is the first in a run of adjacents, handle the run-->
<xsl:if test="not(from-preceding-siblings(*[position()=1 and  
     <xsl:apply-templates mode="grab" select="."/>
      <!--otherwise, this isn't the first, so it must have been handled-->

  <!--walk along adjacent elements of same name, tracking concatenation-->
<xsl:template mode="grab" match="mi">
<xsl:param-variable name="x" expr="''"/>    <!--first time around empty-->
  <xsl:when test="from-following-siblings(*[position()=1 and 
                 <!--there are more where this came from, keep grabbing-->
     <xsl:apply-templates mode="grab" 
       <xsl:param name="x" expr="concat($x,.)"/>      <!--result so far-->
              <!--we have reached the end of a grouping, put out result-->
     <mi><xsl:value-of select="concat($x,.)"/></mi>

T:\FTEMP>call xsl test.xml test.xsl testout.xml
T:\FTEMP>type testout.xml


G. Ken Holman                    mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Crane Softwrights Ltd.   
Box 266, Kars, Ontario CANADA K0A-2E0   +1(613)489-0999   (Fax:-0995)
Website:  XSL/XML/DSSSL/SGML services, training, libraries, products.
Publications:   Introduction to XSLT (3rd Edition) ISBN 1-894049-00-4
Next instructor-led training:   MS'99 1999-08-16  MT'99 1999-12-05/06

 XSL-List info and archive:

Current Thread