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

RE: XML to Table

Subject: RE: XML to Table
From: "Andreas L. Delmelle" <a_l.delmelle@xxxxxxxxxx>
Date: Tue, 20 Apr 2004 18:49:33 +0200
veronica sanchez video
> -----Original Message-----
> From: Veronica Sanchez [mailto:vsguiseris@xxxxxxxxxxx]
>

Hi,

> thanks!!! Both suggestions have been very useful to me, but now I
> have two
> xsl that make the transform quickly:
>
<snip />
> What is better, with or without templates?
>

AFAICT, it doesn't really matter (so, depends on what you would define as
'better'). WRT processing-speed, I guess the difference between the two
solutions is negligeable.

The main difference is in the modularity. In the first solution (using
xsl:for-each), all relevant code is put inside one and the same template,
which in turn will lead to code that is rather awkward to read, understand
or maintain. The second solution puts all different bits of code inside
separate templates, making it very easy to modify (or replace) one piece of
the processing, or to include/import the templates in other stylesheets.

The solution with the templates is certainly more in sync with the general
XSLT processing-model (apply-templates and let the processor walk the tree),
whereas the xsl:for-each approach leans more toward the 'classic'
programming-languages, where it's all about iterations (loops). So, in this
case, as said, it doesn't really matter, but if you're going to write more
XSL stylesheets (most likely more complex than this example) it's certainly
'better practice' to try to adhere as much as possible to the matching
templates approach.

As a general tip, keep in mind that from an XSLT point-of-view, xsl:for-each
should be the last possibility entering your mind:

<xsl:for-each select="nodes">
  <!-- transform -->
</xsl:for-each>

achieves the same result as

<xsl:template match="parent-node">
  <xsl:apply-templates select="nodes" />
</xsl:template>

<xsl:template match="nodes">
  <!-- transform -->
</xsl:template>

The cases for which this is not true, or even undesirable, are rare.


Hope this clarifies it somewhat...

Cheers,

Andreas

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.