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

Re: Performance Issue (if any?)

Subject: Re: Performance Issue (if any?)
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Mon, 14 May 2001 10:51:43 +0100
makecards
Hi Robin,

> Just wondering if there are any performance issues and/or preferred
> methods of deciding when it is best to use <xsl:call-template
> name="whatever"> over <xsl:template match="somenode"
> mode="withmode">. In this case, I only need to make 2 passes (so
> far!), so is there any difference really?

In answer to the general question, it's probably slightly easier for a
processor to find a named template than a matching template, so it
might be slightly more efficient to use a named one, but not so much
that it's worthwhile at the expense of complicating your stylesheet.

In this case, the content of the template that you're talking about
has no reliance on the current node when it's called - it collects all
the employees together and creates a card for each of them.  I would
therefore make it a named template (especially as you might
accidentally apply it to more than one employee, which mean it created
cards for all the employees multiple times).

Personally, though, I wouldn't have the xsl:for-each that you have,
and instead I'd work down the hierarchy to build up the cards for each
employee.  The top-level template would look like:

<xsl:template match="employeehierarchy">
   <wml>
      <card id="employees">
         <p>Employees</p>
         <p><xsl:apply-templates /></p>
      </card>
      <xsl:apply-templates mode="makeCards"/>
   </wml>
</xsl:template>

The employee-matching template in the default mode would look roughly
the same as it does at the moment:

<xsl:template match="employee">
   <!--Build the wml cards-->
   <!--Build the card that lists the employees-->

   <a href="#{emplast}"><xsl:value-of select="emplast"/></a>
   <xsl:value-of select="concat(', ', empfirst, ' ', empmiddle)" />
   <br/>
   <xsl:apply-templates select="employees" />
</xsl:template>

[Changes here were to use an attribute value template rather than
xsl:attribute, to use xsl:value-of to create the string (just to save
space), and to apply templates to employees and let the built-in
templates do their work.]

Then I'd have an employee-matching template in makeCards mode that
looked like, the following. This works through the employees
recursively, making a card for each of them, a lot like the template
above, rather than iterating over them using xsl:for-each:

<!--Build the cards that list each individual employee-->
<xsl:template match="employee" mode="makeCards">
   <card id="{emplast}">
      <p>
         <xsl:value-of select="concat(emptitle, ' ', empfirst, ' ',
                                      emplast)" />
         <br/>
      </p>
      <p>Position:<br/>
         <xsl:value-of select="empposition"/>
         <br/>
      </p>
      <p>Job Description:<br/>
         <xsl:value-of select="empdescription"/>
         <br/>
      </p>
      <p>Extension:<br/>
         <xsl:value-of select="empextension"/>
         <br/>
      </p>
   </card>
   <xsl:apply-templates select="employees" mode="makeCards" />
</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

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.