This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

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@mulberrytech.com
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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]