Tuesday, September 11, 2007

Αλγοριθμος επαληθευσης ΑΦΜ σε XPath

In order to validate the check digit of the Greek Tax ID(ΑΦΜ) using XPath expression is much more concise compared to other languages:

string-length(.) = 9 and
substring(., 9,1) = (
substring(., 1,1) * 256 +
substring(., 2,1) * 128 +
substring(., 3,1) * 64 +
substring(., 4,1) * 32 +
substring(., 5,1) * 16 +
substring(., 6,1) * 8 +
substring(., 7,1) * 4 +
substring(., 8,1) * 2
) mod 11 mod 10

This expressions is useful for XForms applications.

No comments:

Post a Comment