Skip to content

Instantly share code, notes, and snippets.

@jonelf
Created September 17, 2014 07:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonelf/188343b2070354a00513 to your computer and use it in GitHub Desktop.
Save jonelf/188343b2070354a00513 to your computer and use it in GitHub Desktop.
Validera personnummer i XPATH
(validate-dateTime("yyyyMMdd", left($pnum, 8 )))
and
(((number(substring($pnum,3,1))*2) mod 9 + (floor(number(substring($pnum,3,1)) div 9)*9) + (number(substring($pnum,4,1))) +
(number(substring($pnum,5,1))*2) mod 9 + (floor(number(substring($pnum,5,1)) div 9)*9) + (number(substring($pnum,6,1))) +
(number(substring($pnum,7,1))*2) mod 9 + (floor(number(substring($pnum,7,1)) div 9)*9) + (number(substring($pnum,8,1))) +
(number(substring($pnum,9,1))*2) mod 9 + (floor(number(substring($pnum,9,1)) div 9)*9) + (number(substring($pnum,10,1))) +
(number(substring($pnum,11,1))*2) mod 9 + (floor(number(substring($pnum,11,1)) div 9)*9) + (number(substring($pnum,12,1)))
) mod 10 = 0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment