Re: [xsl] Built in templates

Subject: Re: [xsl] Built in templates
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Thu, 5 Apr 2001 11:24:19 +0100
Hi Richard,

> Well I can't remember the exact name but there are builtin rules
> that for example copy all the text() elements accross into the
> output from unrecognised nodes. I want this not to be the case so I
> overrode it like...
> <xsl:template match="text()"></xsl:template>
> ...however I tend to use a lot of different modes in my mechanism
> and it seems I need to override the builtin template for each and
> every mode - this is not nice. Anybody have any ideas?

Hmm... this is interesting. In the section on Built-In Templates in
XSLT 1.0, the only moded built-in template is:

<xsl:template match="*|/" mode="m">
  <xsl:apply-templates mode="m"/>

This propagates the application of templates in that mode down the
node tree. I can't see anywhere where it says that there is a built-in
template like:

<xsl:template match="text()" mode="m">
  <xsl:value-of select="."/>

But I must have missed something because Saxon, MSXML and Xalan all
seem to operate as if there is.

Anyway, a solution might be to only *apply* templates to the nodes
that you *are* interested in, rather than just applying templates to
everything and filtering out the stuff you're *not* interested in.

This shifts those parts of your stylesheet from a 'push' style, driven
by the source document (apply templates to everything and let the
templates determine what they do with which) to a 'pull' style, driven
by the stylesheet (only apply templates to the things you want to get
output for).

I hope that helps,


Jeni Tennison

 XSL-List info and archive:

Current Thread