[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
has not caption
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.