[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Simple Problem
At 28 Apr 2000 10:45 PDT, Mark Swardstrom wrote: > So, my question remains, how can I treat elements without explicit string > data (such as <root> or <node> below) differently than those with data? Every element node has a string value that is the concatenation of all of its text node descendants. You appear to be only interested in text node children, and don't appear to want to count text nodes containing only whitespace characters (e.g. the line feed and space characters between the <root> and <node> start tags in your sample document). Try this: ------------------------------------------------------------ <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <!-- Strip text nodes containing only whitespace characters --> <xsl:strip-space elements="*"/> <!-- Match elements that DO NOT have text node children --> <xsl:template match="*[not(child::text())]"> <p><xsl:value-of select="name()"/> has no (non-stripped) text children.</p> <xsl:apply-templates/> </xsl:template> <!-- Match elements that aren't matched by higher-priority rule --> <xsl:template match="*"> <p><xsl:value-of select="name()"/> has (non-stripped) text children.</p> <xsl:apply-templates/> </xsl:template> <!-- Suppress text nodes because we just want our messages --> <xsl:template match="text()"/> </xsl:stylesheet> ------------------------------------------------------------ Regards, Tony Graham ====================================================================== Tony Graham mailto:tgraham@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9632 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
|
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
|