- markup (52)
- xml (7)
- xslt (21)
- atom (8)
- overlapping markup (2)
- schema (9)
- creole (4)
- xforms (1)
- pipelines (7)
- coding (2)
- dtll (1)
- genealogy (3)
- gtd (1)
- hardware (1)
- legislation (1)
- ontologies (2)
- unicode (1)
- web (24)
- google (3)
- rdf (6)
- rest (3)
- wikis (1)
- work (1)
- xpath (1)
- xquery (1)
- xtech2008 (3)
- life (26)
- children (5)
- equality (6)
- environment (4)
- gadgets (5)
- software (3)
- xlinq (2)
- conferences (7)
- xtech (6)
- blog (7)
- drupal (3)
Re: Levenshtein distance in XSLT 2.0
I implemented an XQuery version of the naive algorithm a little while back for a user on our forums:
http://forums.oracle.com/forums/thread.jspa?messageID=1570246�
declare function local:lev($arg1 as xs:string, $arg2 as xs:string) as xs:decimal? { if(string-length($arg1) = 0) then string-length($arg2) else if(string-length($arg2) = 0) then string-length($arg1) else min(( local:lev(substring($arg1, 2), $arg2) + 1, local:lev($arg1, substring($arg2, 2)) + 1, local:lev(substring($arg1, 2), substring($arg2, 2)) + (if(substring($arg1, 1, 1) = substring($arg2, 1, 1)) then 0 else 1) )) };Personally I think I find it easier to read with a non-XML syntax - but maybe I just haven't spent long enough looking at XSLT code.