xml editor

Supported platforms

Compatible with Windows7 & Mac OS X Snow Leopard

Ready for data server software
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

RE: Simple Problem


Subject: RE: Simple Problem
From: Tony Graham <tgraham@xxxxxxxxxxxxxxxx>
Date: Fri, 28 Apr 2000 15:10:32 -0400 (EST)

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



Current Thread
Keywords
xml
XML Editor | XML Author | WYSIWYG Editors | Schema Editor | XSD Documentation | XSL/XSLT Editor | XQuery | XML Databases | SVN Client
© 2002-2011 SyncRO Soft Ltd. All rights reserved. | Sitemap | Privacy Policy | This website was created & generated with <oXygen/>®XML Editor