|
I found this article while searching for a way to validate ISBNs using Schematron. The article hints that this is possible, but doesn't give an example. For future reference, the following XPath expression can be used in schematron as the "test" attribute of an "assert" element:
substring(
'0123456789X',
11 + 1 - (
10 * substring(translate(., ' -', ''), 1, 1) +
9 * substring(translate(., ' -', ''), 2, 1) +
8 * substring(translate(., ' -', ''), 3, 1) +
7 * substring(translate(., ' -', ''), 4, 1) +
6 * substring(translate(., ' -', ''), 5, 1) +
5 * substring(translate(., ' -', ''), 6, 1) +
4 * substring(translate(., ' -', ''), 7, 1) +
3 * substring(translate(., ' -', ''), 8, 1) +
2 * substring(translate(., ' -', ''), 9, 1)
) mod 11,
1
) = substring(translate(., ' -', ''), 10, 1)
|