[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: XSLT Processor - root node template & version ques

Subject: Re: XSLT Processor - root node template & version question
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Thu, 10 Oct 2002 00:38:42 +0100
xslt match root node
Hi Will,

> Q1: Does it matter (speed wise or best practice) if a template is
> defined for the root element? My understanding is that the root node
> is automatically processed first by the processor.

My practice is to match the root node but to use it purely as a
routing mechanism for directing processing off to a template matching
the document element in a particular mode. In other words, all
templates but the template matching the root node have a mode, and the
root node is just used to choose that mode:

<xsl:template match="/">
  <xsl:apply-templates mode="html" />
</xsl:template>

<xsl:template match="RouteCodeMaintLookup" mode="html">
  <html>
    ...
  </html>
</xsl:template>

My reasoning is that this helps maintenance because it makes it easier
to merge stylesheets together, particularly when you're merging them
to create a pipeline within the stylesheet. For example, it would be
easy to import this stylesheet and another stylesheet into a
stylesheet with a single template, matching the root node, that does
something like:

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

It's a lot harder to merge stylesheets when the templates in them all
use the same (default) mode and when the bulk of the processing is
done in the template matching the root node.

> Q2: Since the XSLT 1.1 never made it past WD status is there any
> gain in specifying it? I use Xalan-j.

No, there's no benefit; don't specify 1.1.

Cheers,

Jeni

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


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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.