Re: [xsl] XSLT Lint 0.1

Subject: Re: [xsl] XSLT Lint 0.1
From: Michael Kay <mike@xxxxxxxxxxxx>
Date: Mon, 14 Feb 2011 13:48:14 +0000
On 14/02/2011 13:32, Andriy Gerasika wrote:
Hello,
last couple of days I have been working on IMHO an interesting project -- XSLT Lint.



While this is laudable, a refactoring like this one:


<!-- old -->
<xsl:variable name="varName">
<xsl:value-of select="xpath"/>
</xsl:variable>
<!-- new -->
<xsl:variable name="varName" select"xpath"/>

isn't safe without first doing a lot of semantic analysis. I think the preconditions for this to be correct are something like:

"all uses of $varName are dependent only its string value"

For example, if the xpath is //a, where a is an element that does not exist, then boolean($varName) is true before your refactoring, and false after it. Similary, <xsl:apply-templates select="$varName"/> will give completely different results before and after.

It looks to me as if your tool is trying to do refactorings based purely on local textual pattern matching. That might give good results 95% of the time, but 95% seems inadequate to me.

Michael Kay
Saxonica

Current Thread