I need to perform validation on the name field to see if it has any illegal characters. Below is the way ma currently doing it
<xsl:variable name="validChars" select="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ. "></xsl:variable> <wd:First_Name> <xsl:variable name="illegalFirst" select="replace($getUserData.firstname, $validChars, '')" /> <xsl:value-of select="replace($getUserData.firstname, $illegalFirst, '')"/> </wd:First_Name>
The first replace() captures any/all illegal characters and the second replace() removes those captured characters.
The problem am facing is, it's not necessary that "Name" will always have some illegal characters. It can be a valid name as well. In this situation, the variable $illegalFirst will be empty. This is throwing an error "An empty sequence is not allowed as the second argument of replace()".
I tried to validate as below
<xsl:if test="string-length($illegalFirst) > 0"> <xsl:value-of select="replace($getUserData.firstname, $illegalFirst, '')"/> </xsl:if> <xsl:if test="string-length($illegalFirst) = 0"> <xsl:value-of select="$getUserData.firstname"/> </xsl:if>
This condition check doesn't seem to work. It still throws the same error message.
Am pulling my hair out since morning. Any help is greatly appreciated.