Q: Validation AlphaNumeric XSLT I was stuck with validation. i can validation when empty string, and validation with length requirement, and validation with just numeric, But when the input was have a special character and have contains alphanumeric. i was stuck. can anyone helping me correct which side i need fix with my code
MYCODE :
<?xml version="1.0" encoding="UTF-8"?>
<localEntry key="LOCAL_XSLT_Validate" xmlns="http://ws.apache.org/ns/synapse">
    <xsl:stylesheet version="1.0" xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
        <xsl:output indent="yes" method="xml" omit-xml-declaration="yes"/>
        <xsl:template match="/">
            <OperationValueRegex>
                <xsl:call-template name="values">
                    <xsl:with-param name="vals" select="//OperationValueRegex/Value"/>
                </xsl:call-template>
            </OperationValueRegex>
        </xsl:template>
        <xsl:template name="values">
            <xsl:param name="vals"/>
            <xsl:choose>
                <!-- Validation Number -->
                <xsl:when test="fn:tokenize($vals, ' ')[matches(., '\d+')] and string-length($vals) = 8">
                    <Result1>
                        <xsl:value-of select="$vals"/>
                    </Result1>
                </xsl:when>
                <xsl:when test="$vals = 'NaN' or string-length($vals) != 8">
                    <Result1>
                        <Value>
                            <xsl:value-of select="$vals"/>
                        </Value>
                        <notification>input was not valid requirement maximum</notification>
                    </Result1>
                </xsl:when>
                <xsl:otherwise>
                    <Result1>
                        <Value>
                            <xsl:value-of select="$vals"/>
                        </Value>
                        <notification>Wrong Format</notification>
                    </Result1>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:template>
    </xsl:stylesheet>
</localEntry>

Request and expected result
{
    "OperationValueRegex" : {
        "Value" : "1234asdv"
    }
}


<OperationValueRegex xmlns="http://ws.apache.org/ns/synapse" xmlns:fn="http://www.w3.org/2005/xpath-functions">
    <Result1>1234asdv</Result1>
    <notification>Wrong Format</notification>
</OperationValueRegex>

Thanks

A: I can found the way for validation Alphanumeric
<?xml version="1.0" encoding="UTF-8"?>
<localEntry key="LOCAL_XSLT_Validate" xmlns="http://ws.apache.org/ns/synapse">
    <xsl:stylesheet version="1.0" xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
        <xsl:output indent="yes" method="xml" omit-xml-declaration="yes"/>
        <xsl:template match="/">
            <OperationValueRegex>
                <xsl:call-template name="values">
                    <xsl:with-param name="vals" select="//OperationValueRegex/Value"/>
                </xsl:call-template>
                <xsl:call-template name="dates">
                    <xsl:with-param name="dats" select="//OperationValueRegex/Date"/>
                </xsl:call-template>
            </OperationValueRegex>
        </xsl:template>
        <xsl:template name="values">
            <xsl:param name="vals"/>
            <xsl:choose>
                <!-- Validation Number -->
                <xsl:when test="fn:matches($vals, '^\d+$') and string-length($vals) = 8">
                    <Result1>
                        <xsl:value-of select="$vals"/>
                    </Result1>
                </xsl:when>
                <xsl:when test="$vals = 'NaN' or string-length($vals) != 8">
                    <Result1>
                        <Value>
                            <xsl:value-of select="$vals"/>
                        </Value>
                        <notification>input was not valid requirement maximum</notification>
                    </Result1>
                </xsl:when>
                <xsl:when test="fn:matches($vals, '^[a-zA-Z0-9_]*$') and string-length($vals) > 0">
                    <Value>
                        <xsl:value-of select="$vals"/>
                    </Value>
                    <notification>Wrong Format</notification>
                </xsl:when>
            </xsl:choose>
        </xsl:template>
        <xsl:template name="dates">
            <xsl:param name="dats"/>
            <xsl:variable name="dateString">
                <xsl:value-of select="substring($dats,1,4)"/>
                <xsl:text>-</xsl:text>
                <xsl:value-of select="substring($dats,5,2)"/>
                <xsl:text>-</xsl:text>
                <xsl:value-of select="substring($dats,7,2)"/>
            </xsl:variable>
            <RequiredFormat>
                <xsl:value-of select="format-date(xs:date($dateString), '[Y]/[M]/[D]')"/>
            </RequiredFormat>
            <OtherFormat>
                <xsl:value-of select="format-date(xs:date($dateString), '[MNn] [D], [Y]')"/>
            </OtherFormat>
        </xsl:template>
    </xsl:stylesheet>
</localEntry>

But I still have trouble with when input was have special character like = "@+./!~`*%^$()-@". Need little more help about this
