This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: Best practices
- From: "Michael Kay" <michael dot h dot kay at ntlworld dot com>
- To: <xsl-list at lists dot mulberrytech dot com>
- Date: Tue, 18 Jun 2002 18:29:23 +0100
- Subject: RE: [xsl] Best practices
- Reply-to: xsl-list at lists dot mulberrytech dot com
> From a design standpoint, what is the "defacto" way to test
> for an empty element?
You have to be very careful what you mean by an "empty element". Which
of the following are empty?
<p/>
<p> </p>
<p><!-- this is empty --></p>
<p><i></i></p>
p='' checks that the element exists and has an empty string-value: it
will match 1,3,4 in the above list, and 2 if xsl:strip-space is in use.
not(p/node()) checks that the element exists and has no children: it
will match item 1 in the above list.
not(normalize-space(p)) will match all the above.
Michael Kay
Software AG
home: Michael.H.Kay@ntlworld.com
work: Michael.Kay@softwareag.com
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list