[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Updating XML

Subject: Re: Updating XML
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Tue, 17 Dec 2002 17:02:28 +0000
Re:  Updating XML
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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.