Subject: Re: [xsl] testing element's contents|
From: Joerg Heinicke <joerg.heinicke@xxxxxx>
Date: Thu, 03 Oct 2002 21:40:46 +0200
test="descendant::*[not(self::Link or self::Media or self::Caption)] | descendant::text()[normalize-space()][not(parent::Caption)]]"
Thanks. Very close now...
The only thing causing a problem now is that a Media element can contain two child elements, Link and/or Caption. I actually had a Link element outside of a Media element before, but that *SHOULD* not happen. Both the Link and Caption elements contain text nodes. So, something like this:
<p> <Media type="image" id="1" file="http://www.mylocal.gov/images/aero.gif" width="54" height="54" border="" alt="Picture of the shuttle parachute."> <Link url="mytestfile.htm" type="external"/> <Caption align="bottom">Picture of the shuttle parachute.</Caption> </Media> </p>
will pass the test even though it is only an image.
Sorry I left that out. That is the only snag left preventing your solution from working.
I tried adding to it myself, but I just do not understand axis conditionals well enough.
<xsl:when test="descendant::node()[normalize-space()][not(self::Media or descendant::Link or descendant::Caption)]"> <p><xsl:apply-templates/></p> </xsl:when>