ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> xsl-list
xsl-list
Re: [xsl] Measuring the complexity of XSLT stylesheets
by Adam Turoff other posts by this author
Apr 19 2005 1:31PM messages near this date
Re: [xsl] Measuring the complexity of XSLT stylesheets | Re: [xsl] Measuring the complexity of XSLT stylesheets
& XSLT On 4/17/05, Dimitre Novatchev <dnovatchev@[...].com>  wrote:
>  On 4/18/05, Lars Marius Garshol <larsga@[...].no> 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

--~------------------------------------------------------------------
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@[...].com> 
--~--
Thread:
Lars Marius Garshol
Anthony B. Coates
James Fuller
Dimitre Novatchev
Lars Marius Garshol
Dimitre Novatchev
Adam Turoff
M. David Peterson
Sebastien Arbogast
Lars Marius Garshol
Jirka Kosek

Lars Marius Garshol
James Fuller
Lars Marius Garshol
Colin Paul Adams
M. David Peterson
M. David Peterson
Jun Zhang
M. David Peterson
Francesco Barresi
Ben Pickering
Lars Marius Garshol
M. David Peterson
Colin Paul Adams

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved