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

Re: Performance Question: Expensive Functions in Pred

Subject: Re: Performance Question: Expensive Functions in Predicates
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Thu, 27 May 2004 12:03:29 -0400
id idrefs
At 2004-05-27 10:35 -0500, Eliot Kimber wrote:
I have a general question about predicting performance in the general case. I know that the best answer is "try it and see" but I'm wondering if there's a general principle that can guide design in this particular case.

I approach applicability/effectivity in multiple configurations of my training material using ID/IDREFS as an alternative to the methods you cited. I cannot comment specifically on the performance but thought I would share what I do as an alternative approach that does not use extension functions.


My question is where, in general, is the best place to use these functions:

- In apply-templates specifications?

- In match specifications?

- As IF blocks within templates?

For example, I could do this:

<xsl:apply-templates select="*[util:is_applicable()]"/>

Or

<xsl:template match="foo[util:is_applicable()]">

or

<xsl:template match="foo">
  <xsl:if test="util:is_applicable()">
  </xsl:if>
</xsl:template>

I have an external entity with each identified applicability using ID:


<appls>
  <appl id="this" appl="yes"/>
  <appl id="that" appl="no"/>
  <appl id="other" appl="yes"/>
</appls>

that I pull into my instance.

And then in my instance content I state the applicability indirectly through the labelled applicabilities using IDREFS:

<thing1 appl="this">...

<thing2 appl-or="this that">...

<thing3 appl-and="this other">...

And then I use XSLT and node-set comparison to determine applicability:

<xsl:if test="id(@appl)='yes'">...then applies when it says so...

<xsl:if test="id(@appl-or)='yes'">...then applies when any apply...

<xsl:if test="not(id(@appl-and)!='yes')">...then applies when all apply...

I'm not sure what you are doing in your extension function, but mine would not address any database lookup or other out-of-line check for applicability.

Being able to edit the instance of applicabilities is a nice convenience for me.

Another option of course is to do the applicability processing as a separate step so that the base processing templates don't have to care about applicability.

Yes, this is one of the first steps of my training material assembly: using ID/IDREFS to get rid of inapplicable content.


That would ensure that each element is only processed once for applicability but might introduce other performance or scalability issues since one would have to generate either a new serialized instance or a new result tree reflecting the input document(s).

Or just pass the tree to the next step using SAX events in-memory.


It would be a cleaner engineering solution as it would mean base template writers wouldn't have to know about the need to do applicability checks.

Indeed ... when writing the presentation aspects of my environment I didn't have to worry about applicability.


I see the three phases as:

  - authoring (creating the raw content)
  - production (determining the applicable content)
  - publishing (acting on the assembled result to produce multiple outputs)

... where applicability is the second step (after assembly) of the production phase.

I hope this helps.

.......................... Ken

--
Public courses: Spring 2004 world tour of hands-on XSL instruction
Next: 3-day XSLT/XPath; 2-day XSL-FO - Birmingham, UK June 14,2004

World-wide on-site corporate, govt. & user group XML/XSL training.
G. Ken Holman                 mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/s/
Box 266, Kars, Ontario CANADA K0A-2E0    +1(613)489-0999 (F:-0995)
Male Breast Cancer Awareness  http://www.CraneSoftwrights.com/s/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal

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.