This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: Built in templates
- To: Richard Mitchell <Richard dot Mitchell at vbnonline dot com>
- Subject: Re: [xsl] Built in templates
- From: Jeni Tennison <mail at jenitennison dot com>
- Date: Thu, 5 Apr 2001 11:24:19 +0100
- CC: "'XSL'" <xsl-list at lists dot mulberrytech dot com>
- Organization: Jeni Tennison Consulting Ltd
- References: <191E23677373D411BFB900D0B7A7BA28025C47@mail.vbninternal.com>
- Reply-To: xsl-list at lists dot mulberrytech dot com
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?
<aside>
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"/>
</xsl:template>
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="."/>
</xsl:template>
But I must have missed something because Saxon, MSXML and Xalan all
seem to operate as if there is.
</aside>
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
---
Jeni Tennison
http://www.jenitennison.com/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list