This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: default template (was:RE: text() and not())
- From: David Carlisle <davidc at nag dot co dot uk>
- To: xsl-list at lists dot mulberrytech dot com
- Date: Tue, 8 Jan 2002 15:57:08 GMT
- Subject: Re: default template (was:RE: [xsl] text() and not())
- References: <003401c19851$e172bad0$8ac809c0@ajw>
- Reply-to: xsl-list at lists dot mulberrytech dot com
> As I understand, <xsl:apply-templates/> will read through the
> source xml and look for templates in the stylesheet to process them
> with.
it won't look all through the XML file if that's what you mean,
xsl:apply-templates without a select attribute is equivalent to
<xsl:apply-templates select="node()"/>
so just selects the child elements, as the current node is th eroot,
there will just be one element selected (plus any comments or process
instructions at the top level)
> in which case, I
> have to include my own template to do nothing,
yes and no.
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
<x>
<a>a text</a>
<b>b text</b>
<c>c text</c>
</x>
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]"/>
David
_____________________________________________________________________
This message has been checked for all known viruses by Star Internet
delivered through the MessageLabs Virus Scanning Service. For further
information visit http://www.star.net.uk/stats.asp or alternatively call
Star Internet for details on the Virus Scanning Service.
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list