This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: <xsl:apply-templates select="not('nodename')"/> ?
- From: Stuart Brown <sbrown at extenza dot co dot uk>
- To: "'xsl-list at lists dot mulberrytech dot com'" <xsl-list at lists dot mulberrytech dot com>
- Date: Tue, 27 Aug 2002 16:15:41 +0100
- Subject: RE: [xsl] <xsl:apply-templates select="not('nodename')"/> ?
- Reply-to: xsl-list at lists dot mulberrytech dot com
Hi Michael,
> I would like to preferentially list some children ahead of
> others. I'm
> trying to do it like this:
>
> <xsl:apply-templates select="./apple"/>
> <xsl:apply-templates select="./orange"/>
> <xsl:apply-templates select="not(apple|orange)"/>
>
> ... I want for the third line to process all other children. It's not
> working that way though. What's the right syntax to achieve this?
It's probably better to use template modes for this:
<xsl:apply-templates mode="doApples"/>
<xsl:apply-templates mode="doOranges"/>
<xsl:apply-templates mode="theRest"/>
<!-- Apples mode: process apple and ignore everything else -->
<xsl:template match="apple" mode="doApples">
<xsl:copy/>
</xsl:template>
<xsl:template match="*" mode="doApples"/>
<!-- Oranges mode: process orange and ignore everything else -->
<xsl:template match="orange" mode="doOranges">
<xsl:copy/>
</xsl:template>
<xsl:template match="*" mode="doOranges"/>
<!-- The rest: ignore apples and oranges -->
<xsl:template match="apple | orange" mode="theRest"/>
<xsl:template match="mango" mode="theRest">
<xsl:copy/>
</xsl:template>
<xsl:template match="durian" mode="theRest">
<xsl:copy/>
</xsl:template>
If you really want to do it your way, use select="not(name() = 'apple' or
name() = 'orange')".
Hope this helps,
Stuart
> -----Original Message-----
> From: Michael Rothwell [mailto:rothwell@holly-springs.nc.us]
> Sent: 27 August 2002 16:02
> To: xsl-list@lists.mulberrytech.com
> Subject: [xsl] <xsl:apply-templates select="not('nodename')"/> ?
>
>
> I would like to preferentially list some children ahead of
> others. I'm
> trying to do it like this:
>
> <xsl:apply-templates select="./apple"/>
> <xsl:apply-templates select="./orange"/>
> <xsl:apply-templates select="not(apple|orange)"/>
>
> ... I want for the third line to process all other children. It's not
> working that way though. What's the right syntax to achieve this?
>
> Thanks,
>
> -M
>
>
> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list