Re: [xsl] Inserting Elements with XSL

Subject: Re: [xsl] Inserting Elements with XSL
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Mon, 4 Jun 2001 09:20:46 +0100
Hi Joerg,

> I tried
>
>   <xsl:template match="(a|b|c|d|e)[not(following-sibling::b|following-sibling::c|
>     following-sibling::d|following-sibling::e|following-sibling::f)]">
>     <xsl:copy-of select="."/>
>     <f/>
>   </xsl:template>
>
> but this is apparently not a valid match pattern (saxon 6.3 complains).
> And it's not really more comprehensible.
>
> Using
>   <xsl:template match="*[(name()='a' or name()='b' or ...)
>                          and not(following-sibling::*[name()='b' or ...])]">
>     <xsl:copy-of select="."/>
>     <f/>
>   </xsl:template>
>
> isn't all that much more attractive either.

Well, your match pattern above is the same as:

  *[self::a or self::b or self::c or self::d or self::e or self::f]
   [not(following-sibling::*
           [self::a or self::b or self::c or self::d or self::e or
           self::f])]

This will match any a, b, c, d, e or f element that doesn't have a
following a, b, c, d, e or f element as a sibling.  In other words, it
matches the last a, b, c, d, e or f element within its parent.  A
simpler way of doing that would be:

  *[self::a or self::b or self::c or self::d or self::e or self::f]
   [last()]

I hope that helps,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread