Re: [xsl] XSLT Output contains the unwanted content of all elements as text

Subject: Re: [xsl] XSLT Output contains the unwanted content of all elements as text
From: Abel Braaksma <abel.online@xxxxxxxxx>
Date: Thu, 08 Mar 2007 17:03:04 +0100
Florent Georges wrote:
<xsl:template match="*"/>

With the OP example, that will result in no output at all, as the root element will match this template rule and no other processing will be done. But off course that depends on the whole, real stylesheet of the OP. Maybe the following can help him, too:

<xsl:template match="text()"/>

Florent, that is not the case. Though I often use your throw-away template because it is so easy and has clear semantics, the normal precedence rules apply, even if you use the element() constructor for a match (which is, I believe, a bit odd though). The OP had:


<xsl:template match="element(zoo:country)">

which is the long form of saying:


<xsl:template match="zoo:country" >...


and a specific element reference has a higher precedence than a generic one. So, adding something like:


<xsl:template match="*" />


will work, and will still call the appropriate other templates in due cause. In cases where you have large input document with many elements and only a few needs to be processed, I believe that it is a bit faster than the text() node approach (some estimate I like to refer to as running time by granularity approximation, but I may be wrong).


-- Abel

Current Thread