Schematron validation for string value

Having trouble deploying Oxygen XML Web Author? Got a bug to report? Post it all here.
sandy99
Posts: 1
Joined: Fri May 17, 2019 5:22 am

Schematron validation for string value

Post 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?
tavy
Posts: 388
Joined: Thu Jul 01, 2004 12:29 pm

Re: Schematron validation for string value

Post 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
Octavian Nadolu
<oXygen/> XML Editor
http://www.oxygenxml.com
Post Reply