RE: [xsl] Exclude elements in transformation

Subject: RE: [xsl] Exclude elements in transformation
From: "Andrew Welch" <ajwelch@xxxxxxxxxxxxxxx>
Date: Thu, 16 Sep 2004 10:40:59 +0100
> I want to exclude each element that is preceeded by a
> specific tag, call it A.
>
> So i have XML like:
>
> <A>blah</A>
> <B>blub</B>
>
> I have a XSLT template for A and that includes the following
> element (B here). So now i need a template for each element
> that is preceeded by A and does nothing, but i don't know the
> Xpath expression or it.

This will do what you ask:

<xsl:template match="*[preceding-sibling::A]"/>

But I suspect there might be a better solution - I think it's preferable
to not select the nodes to process in the first place, rather than
select everything and use a no-op template to suppress the things you
don't want.  You would need to give a little more information for that
kind of answer.

cheers
andrew

Current Thread