Page 1 of 1

Representing all alphabets in a string

Posted: Thu Jul 14, 2016 10:18 am
by Raga Mounika
Hi Team,

I have to write a schematron rule in XSLT 1.0 to represent all the lower case alphabets and digits in a single string.
I used the below code and it is not working.

contains($text, '^[a-z0-9]+$')

Please help me in solving this issue.

Thank you!

Regards,
Mounika

Re: Representing all alphabets in a string

Posted: Thu Jul 14, 2016 2:21 pm
by tavy
Hello,

Because you are using Schematron with XSLT 1.0, you cannot apply a regular expressions to match a string.
A solution for XSLT 1.0 to check is if lower case alphabets and digits are used in a text is to use the translate(). Something like in the following example:

Code: Select all


<sch:let name="vLower" value="'abcdefghijklmnopqrstuvwxyz'"/>
<sch:let name="vDigits" value="'0123456789'"/>
<sch:let name="vAlpha" value="concat($vLower, $vDigits)"/>

<sch:assert test="translate($text,$vAlpha,'') = ''">Message...</sch:assert>
Best Regards,
Octavian