Subject: Re: Testing for presence of node
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Fri, 21 Jun 2002 17:21:21 -0400
|
Dhruv,
At 04:45 AM 6/22/2002, you wrote:
All points are valid, except :
> 4. The guy wants to know if the subcategory element exists, not if it
> has non-empty text content.
*[name()='subcategory'] gives the child-node 'subcategory', not the content.
Yes but string-length(*[name()='subcategory']) returns the length of the
string value of the (first) node in its argument node-set. That's its
content. If the subcategory node existed but had no value, as in
<subcategory/>, then its string-length would be 0 and your test would fail.
One reason to prefer simpler code is that it's less likely to break and
return something not what you meant at all.
Cheers,
Wendell
======================================================================
Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx
Mulberry Technologies, Inc. http://www.mulberrytech.com
17 West Jefferson Street Direct Phone: 301/315-9635
Suite 207 Phone: 301/315-9631
Rockville, MD 20850 Fax: 301/315-8285
----------------------------------------------------------------------
Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|