[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: default template (was:RE: text() and not())

Subject: Re: default template (was:RE: text() and not())
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Tue, 08 Jan 2002 14:59:24 -0500
xsl suppress text

Also, following David's example (below), if inside x you only want to process a, an <xsl:apply-templates select="a"/> is very effective. Combining this with the empty template approach David shows, and you almost never have to suppress text nodes.

Getting rid of text you don't want by overriding the default template matching "text()" seems like an effective expedient until you start discovering how often you need to override your own new default. I think that's the situation you're in.

One gotcha to watch out for is that the expression <xsl:value-of select="text()"/> does not get you the value of all text node children of the current node, but only of the first one. So xsl:value-of is less useful than it might first appear, and has to be used with this limitation in mind.


At 10:57 AM 1/8/02, David wrote:
If you have an element <x> that has all sorts of children that yuu don't
want to process, it is more nomal to have a template for x which does
not call apply-templates and so naturally doesn't process its children
than it is to use a template for x that does use apply templates and
then make templates for each child that does nothing.

If only some of x's children need zapping, suppose you have

<a>a text</a>
<b>b text</b>
<c>c text</c>

and yoy want b to go, it is more natural to say

<xsl:template match="b"/>

ie have an empty template for b than to allow b to have the default
template which would process its text child, and then have

<xsl:template match="text()[parent::b]"/>


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

Current Thread


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.