xsl-list
[Top] [All Lists]

Re: Updating XML

2002-12-17 13:21:58
Hi Jeni,

thanks for your reply. I tried your idea using the self:: axis
and it works pretty good while using a smaller select statement.
I think I will use this one.

Thanks again and greetings,

Marko

At 17:02 17.12.2002 +0000, you wrote:
Hi Marko,

>         <!-- apply all elments except section, simplesect, index and
>               bibliography, but also apply index and bibliography, if
>               they are followed by an element which is not index or
>               bibliography -->
>        <xsl:apply-templates select="*[(
>                    not(name() = 'section') and
>                    not(name() = 'simplesect') and
>                    not(name() = 'index') and
>                    not(name() = 'bibliography')
>                    ) or (
>                    (
>                    name() = 'index' or
>                    name() = 'bibliography'
>                    ) and
>                    following-sibling::*[
>                       not(name() = 'index') and
>                       not(name() = 'bibliography')
>                       ])]"/>

You could simplify this by using the self:: axis rather than testing
using the name() function (the self:: axis is also better because it's
namespace-aware):

  <xsl:apply-templates
    select="*[not(self::section or self::simplesect or
                  self::index or self::bibliography)] |
            (index | bibliography)
              [not(following-sibling::index or
                   following-sibling::bibliography)]" />

Alternatively, you could use a mode. Apply templates in "non-section"
mode:

  <xsl:apply-templates mode="non-section" />

and then have templates in that mode that do nothing for the section
etc. elements:

<xsl:template match="section | simplesect | index | bibliography"
              mode="non-section" />

<xsl:template match="index[not(following-sibling::index or
                               following-sibling::bibliography)] |
                     bibliography[not(following-sibling::index or
                                      following-sibling::bibliography)]">
  ...
</xsl:template>

Cheers,

Jeni

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


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



<Prev in Thread] Current Thread [Next in Thread>