This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Inserting Elements with XSL


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]