Page 1 of 1

Schematron validation for string value

Posted: Fri May 17, 2019 5:28 am
by sandy99
I'm trying to validation a 6 digit number
Example:
1.) 120012
need to validate the above number in Schematron but when I use substring(.,2,5) != "00" it is not validating.
2.) 21
Making the above number to 6 digits value and validating with the above rule doesn't work
3.) similarly I need to validate the above number 000021 not to have 00 in 1st and 2nd position, 00 in 3rd and 4th position, 00 in 5th and 6th position

210021 - the number is bad should throw validation
102101 - the number is good


XML has 21 but appending 000021 in Java and passing it to Schematron
Could you please help?

Re: Schematron validation for string value

Posted: Mon May 20, 2019 2:43 pm
by tavy
Hello,

This is a Schematron issue, therefore I recommend you to use the schematron@schematronist.org user list to get a better response. For this you need to register on the user list "http://schematronist.org/mailman/listin ... ronist.org".
In my opinion you can add 3 checks something like this:
  1. if the '00' is on the first and second position: "substring(.,1,2) != '00'"
  2. if the '00' is on the third and fourth position: "substring(.,3,2) != '00'"
  3. if the '00' is on the fifth and sixth position: "substring(.,5,2) != '00'"


But there are also other solutions, maybe using the "matches()" function and a regular expression.

Best Regards,
Octavian