Re: Levenshtein distance in XSLT 2.0

Odd how appealing expressions like

for $p in (0 to string-length($string1)) return $p

are, even to experts! Fortunately, the optimizer quickly turns them into

(0 to string-length($string1))

It’s one of those things like writing (if ($x=true())…) - somehow we do it even though we know it’s grossly redundant.

I wonder if it’s worth inferring a type of “xs:integer+” for (0 to string-length($string1)) rather than the current “xs:integer*”? In this example we’re doing an unnecessary dynamic type check. No, probably not, special-casing based on single examples has to stop somewhere! Unless the example is in an important benchmark, of course.

Reply

The content of this field is kept private and will not be shown publicly.