Re: [xsl] seriously trivial question about processing the root el ement

Subject: Re: [xsl] seriously trivial question about processing the root el ement
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Thu, 20 Mar 2003 10:45:41 +0000
Hi Dave,

> Jeni said:
>> The pattern that I tend to use is:
>> 
>> <xsl:template match="/">
>>   <xsl:apply-templates select="doc" mode="html" />
>> </xsl:template>
>> 
>> <xsl:template match="doc" mode="html">
>>   ...
>> </xsl:template>
>> 
>> In other words, I use the template matching the root node to start
>> processing using a particular mode. This arrangement makes it easy
>> to combine stylesheets.
>
> Would you then have another mode for print output via xsl-fo Jeni?

I'd have a different *stylesheet* to get XSL-FO. The mode names that I
usually use are based on what the templates in that mode are supposed
to produce. In this stylesheet, 'html' mode would produce HTML, and I
might have other modes such as 'block', 'inline'.

In another stylesheet I might have a 'filter' mode that would filter
the source XML.

When I wanted to filter-and-create-HTML, I'd create a third stylesheet
that imported both the *2html and filter stylesheet, and had a
template matching the root node that would look like:

<xsl:template match="/">
  <xsl:variable name="filtered">
    <xsl:apply-templates select="doc" mode="filter" />
  </xsl:variable>
  <xsl:apply-templates select="exsl:node-set($filtered)/*"
                       mode="html" />
</xsl:template>

Cheers,

Jeni

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


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


Current Thread