|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: XSLT Processor - root node template & version ques
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








