[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
[Recent Entries]
[Reply To This Message]
Re: testing element's contents
Subject: Re: testing element's contents
From: Joerg Heinicke <joerg.heinicke@xxxxxx>
Date: Thu, 03 Oct 2002 21:40:46 +0200
|
So a text node in a <Caption> element shell not cause a <p> in the
output? Ok, no problem, only the XPath becomes more and more complex:
test="descendant::*[not(self::Link or self::Media or self::Caption)]
|
descendant::text()[normalize-space()][not(parent::Caption)]]"
This tests now whether
a descendant element exists, which is not Link, Media or Caption
or
a text node containing non-whitespace characters, which has not Caption
as parent.
| is the union operator, which unions the two node sets descendant::*
and descendant::text(). If the union is not empty, the test is passed.
Regards,
Joerg
Nathan Shaw wrote:
Joerg,
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>
--nate
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
Nathan Shaw - Thu, 3 Oct 2002 12:06:21 -0400 (EDT)
|
|
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format
RSS 2.0 |
|
Atom 0.3 |
|
|