HomePage RecentChanges XSLT Default Rules

A gotcha on XSLT is the default rules. A good article describing them is here: http://www.dpawson.co.uk/xsl/sect2/defaultrule.html

The short version:

A default template exists to expand all elements

#!XML
<xsl:template match="*">
  <xsl:apply-templates/>
</xsl:template>

That way you can make a template that matches an element and you will get to it.

A default template exists for text

#!XML
<xsl:template match="text()">
  <xsl:value-of select="."/>
</xsl:template>

Which always expands the text elements.

How to avoid

The first one is sensible and you should leave it. But you can change the behaviour by writing your own.

The second, text expansion can be changed in one of two ways:

Removing the text node:

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

Software error:

Can't locate object method "endform" via package "CGI" at /data/scott.dd.com.au/wiki/modules/search.pl line 15.

For help, please send mail to the webmaster (webmaster@dd.com.au), giving this error message and the time and date of the error.