xsl-list
[Top] [All Lists]

Re: [xsl] XSLT Optimizer and Deployment

2010-11-16 20:04:19
Thank you for the tips!  I like the warning regarding stripping
white-space, although in a stylesheet I would typically avoid
white-space introduced by an editors linefeed or tab character from a
keystroke and rely only on white-space encoded values.
And yes, this is really not an exercise in performance (but again,
tips appreciated!) but in delivering clean, ready for production,
templates.  So essentially, guaranteeing that you don't leave behind a
big fat "hello, here i am" debug statement to the report.

Karl..

On Tue, Nov 16, 2010 at 4:36 PM, Liam R E Quin <liam(_at_)w3(_dot_)org> wrote:
On Tue, 2010-11-16 at 15:46 -0700, Karl Stubsjoen wrote:
I am writing an XSLT optimizer, basically stripping comments and extra
white-space from an XSLT document for production deployment.

Have you measured the performance difference you get?

Modern XSLT implementations (e.g. Saxon) already do quite a bit
of optimization, at a much less superficial level.  You're
likely to get more mileage adding "as' attributes, replacing =
by eq, and replacing // with explicit paths (depending on the
XML input, and on the XSLT processor - some of those suggestions
depend on using XSLT 2, but if you're on XSLT 1 from 1998, get
with the programme here ;-) )

If you do decide to strip whitespace, make sure you don't do it
inside xsl:text or inside templates containing text that's outside
xsl:text elements.

My optimizer will perform a couple of additional steps:  set default
parameter values for production, make sure logging and other debug
steps are disabled, and so on...

That may make more sense, but again distinguish between setting
default values because they're correct for an environment, turning
off debugging (might want debugging in production, no?) and removing
possibly-sensitive information.

Generally, logging surrounded by
   <xsl:if test="$logBusinessDecisions">...</xsl:if>
isn't going to slow thing down signficantly, and might be useful...

In most cases I've seen, a small change in methods can give a much
greater speedup (orders of magnitudes often) than removing spaces:
e.g. using xsl:key to speed up access of frequently-used patterns,
and checking code that uses idioms like // or preceding::* where not
needed, as these can sometimes lead to O(n^2) or worse behaviour.

Liam


--
Liam Quin - XML Activity Lead, W3C, http://www.w3.org/People/Quin/
Pictures from old books: http://fromoldbooks.org/
Ankh: irc.sorcery.net irc.gnome.org www.advogato.org


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--





-- 
Karl Stubsjoen
MeetScoresOnline.com
(602) 845-0006

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>