xsl-list
[Top] [All Lists]

Re: Measuring the complexity of XSLT stylesheets

2005-04-17 12:23:43
To be honest I have to disagree with any theory that blames the size
of something as the problem...  if its a fairly deep XML infoset with
disparate data types and values galore your XSLT file will, more than
likely, require a lot of templates to properly to process the data.

Again, I think Colin nailed it with the XPath sentence (nice touch
Colin ;)...  take the following for example:

<xsl:for-each select="/foo/bar[(_at_)son_of_bar =
'baby_bar']/preceding:sibling::*[local-name() !=
'little_itty_bitty_foo' and $time_of_day != 'noon' and $phase_of_moon
!= 'full']/@whodafoo =
'great_grand_foo']/following-sibling::barnone/ancestor::*[(_at_)statement =
'whodafooismydaddy?']/descendant-or-self::waitwhat =
'arentwebackwherewestarted?'">
<xsl:for-each select="ah-hell-herewegoagain">
STOP THE MADNESS!!!
</xsl:for-each>
</xsl:for-each>

While I cant speak for anybody else I know I can say with clear
conscience that the above XPath statement and nested xsl:for-each
instructions are an ALL to common occurence when you first start
programming in XML/XSLT and NOTHING compared to just how bad an
attempt to "logically" process XML like this can get.  The secret?

<snip/>

<xsl:apply-templates select="child_element"/>

<xsl:template match="child_element">
... output a value
<xsl:apply-templates/>
</xsl:template>

... more templates to match each element against to determine if it
should be processed further or left alone to be handled by another
template.



On 4/17/05, Lars Marius Garshol <larsga(_at_)garshol(_dot_)priv(_dot_)no> wrote:

* Ben Pickering
|
| Something maybe related to the size of the tree resulting from
| parsing the XPath expression?  The two examples given would be
| closer under this metric than the length of their string
| representations...

True. This metric is clearly better than the character count (which I
had in my original posting, anyway), since it is at least independent
of the length of the element type names and the use of whitespace. It
might not be too hard to write Python script that uses some Python or
Java XPath parser to compute this metric.

--
Lars Marius Garshol, Ontopian         <URL: http://www.ontopia.net >
GSM: +47 98 21 55 50                  <URL: http://www.garshol.priv.no >

--~------------------------------------------------------------------
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>
--~--




-- 
<M:D/>

:: M. David Peterson ::
XML & XML Transformations, C#, .NET, and Functional Languages Specialist

--~------------------------------------------------------------------
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>
--~--