Representing all alphabets in a string

Post here questions and problems related to editing and publishing DITA content.
Raga Mounika
Posts: 49
Joined: Mon Mar 28, 2016 3:54 pm

Representing all alphabets in a string

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

Re: Representing all alphabets in a string

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