Re: [xsl] XPath expression "everything but..." ?

Subject: Re: [xsl] XPath expression "everything but..." ?
From: "Michael Beddow" <mbnospam@xxxxxxxxxxx>
Date: Wed, 14 Feb 2001 15:31:09 -0000
On Wednesday, February 14, 2001 10:47 AM
Fridiric SCHWEBEL wrote:

> Is it possible to have an XPath expression that means "every child
but one"
> ?
> <xsl:template match="chapter">
>    <H1><xsl:apply-templates select="title" /></H1>
>    <xsl:apply-templates select="* but not title" />
> </xsl:template>
Jiri and Francis have provided general solutions (which was what you
asked for) But if the only reason you want to exclude the <title>
element is that you want it, and it alone, to be in an html <h1>
element, there's another way (which may just be less
processor-intensive, I don't know)

Simplify your template to
<xsl:template match="chapter">

Then provide a template matching on "title" (or maybe chapter/title,
depends on your document structure)
that does <h1><xsl:apply-templates/></h1>

Sometimes I think we get a bit carried away with all these clever
brackety quotey thingies. Not everything that works in XSLT is
visually terrifying...

Michael Beddow

 XSL-List info and archive:

Current Thread