Re: [xsl] apply-templates, rule-based, and saxon - REPLY

Subject: Re: [xsl] apply-templates, rule-based, and saxon - REPLY
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Fri, 11 May 2001 08:21:25 +0100
Hi Kevin,

> But isn't this conflicting to the philosophy behind template rules,
> unless I am wrong in my thinking: only if you specify a template
> rule will that element be matched and displayed in the output? Or,
> do I need to match on every element in the source document?

The built-in templates are designed so that you get a behaviour that's
similar to HTML/CSS, where you only have to define rules for the
things that you want to be formatted *differently* - everything gets
shown, but some of it might be in a different colour or whatever. It's
an inheritance from XSL(T)'s background in formatting documents.

If you don't like that behaviour, you can add different default
templates to get the default behaviour you want.  If you want nothing
to be shown by default, then add an empty template that matches the
text() nodes:

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

If you want everything to be copied by default, then add the identity
template as a default:

<xsl:template match="@*|node()">
   <xsl:copy>
      <xsl:copy-of select="@*|node()" />
   </xsl:copy>
</xsl:template>

I hope that helps,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread