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

Re: Measuring the complexity of XSLT stylesheets

Subject: Re: Measuring the complexity of XSLT stylesheets
From: Adam Turoff <adam.turoff@xxxxxxxxx>
Date: Tue, 19 Apr 2005 16:31:34 -0400
halstead complexity
On 4/17/05, Dimitre Novatchev <dnovatchev@xxxxxxxxx> wrote:
> On 4/18/05, Lars Marius Garshol <larsga@xxxxxxxxxxxxxxx> wrote:
> > * Dimitre Novatchev
> > | Cyclomatic Complexity (McCabe) [...]
> > | Halstead Complexity Measures [...]
> > | Henry and Kafura metrics [...]
> > | Bowles metrics [...]
> > | Troy and Zweben metrics [...]
> > | Ligier metrics [...]

Those traditional metrics feel unsatisfying for XSLT.  They all presume
to be analyzing static program text to produce a single scalar value
called "complexity".

With XSLT, the codepaths are determined by the input, so traditional
complexity analysis doesn't really address the problem.  For example,
it's impossible to know if:

    <xsl:apply-templates/>

can trigger zero, one or many templates in a stylesheet.

> > These might all be applicable, but does anyone know of any
> > implementations of these for XSLT?
>
> I don't know of any implementations for XSLT -- these would be best
> implemented as part of an XSLT processor.

This, however, is quite an intriguing idea -- calculate complexity
by tracing stylesheet execution while processing an input document.
Or a series of input documents, varying in complexity.  (Of course,
what constitutes "complexity of an XML document" is a separate
discussion.  ;-) )

Off the top of my head, here are some things that might contribute to
overall stylesheet complexity:

* number of XSLT modules loaded
* overall size of the XSLT stylesheet loaded
  (bytes / nodes post-include, post-import)
* percentage of templates used
* average template size (bytes, nodes, operators, XPath evaluations)
* ratio of input to output size (nodes, bytes)
* percentage of calculated vs. copied output

For example, if I'm processing this DocBook document:

    <book/>

I think we can all agree that there are 57 ways to call the DocBook XSL
stylesheets "complex", at least compared to this stylesheet, which
produces the same output:

    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     version="1.0"/>

:-)

-- Adam

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.