RE: [xslt] Concatenating blocks (and a bit more) with XSLT

Quite smart.. ;) It does work... ;) Thanx

But now, how could I make that generic so that it works on XXX blocks
but also on YYY, ZZZ... w/o duplicating the code ?

Challenging? ;)


-----Original Message-----
From: xslt-bounces gnome org [mailto:xslt-bounces gnome org] On Behalf
Of Igor Zlatkovic
Sent: 27 May 2004 15:54
To: The Gnome XSLT library mailing-list
Subject: Re: [xslt] Concatenating blocks (and a bit more) with XSLT

On 27.05.2004 15:05, Ilpide, Emmanuel wrote:

> Cool! Thanx it does work (with copy-of instead of value-of)... but
> if I want to do the following:
>  * if I have only one of the two blocks (add/delete), these are just
> copied 
>  * if I have the two of them, I concatenate...
> :) ?

Assuming 'delete' always comes first, then use a <xsl:if> to test for 
'add' element along the following-sibling axis.

   <xsl:template match="XXX[ action = 'delete']">
       <xsl:when test="following-sibling::XXX
           [ action = 'add'][position()=1]">
         <XXX action="modify">
            <xsl:copy-of select="old"/>
            <xsl:apply-templates select="following-sibling::XXX
                [ action = 'add'][position()=1]"/>
         <xsl:copy-of select="."/>

   <xsl:template match="XXX[ action = 'add']">
       <xsl:when test="preceding-sibling::XXX
           [ action = 'delete'][position()=1]">
         <xsl:copy-of select="."/>

xslt mailing list, project page
xslt gnome org

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]