You can't put a choose
outside a template
, but you don't need to - you can use predicates in match expressions so just declare your no-op template to match the elements you want to remove:
<xsl:template match="b[@flag='bar']/c" />
or more generally, if the parent of the c
element might have various names
<xsl:template match="c[../@flag='bar']" />
or
<xsl:template match="*[@flag='bar']/c" />