i have a simple operation with choose function. i have planning validation for numeric input json. and response for xml with xslt. after test i got was null with json format. can anyone helping me about this, which one i was wrong.
my code API:
<?xml version="1.0" encoding="UTF-8"?>
<api context="/a" name="A" xmlns="http://ws.apache.org/ns/synapse">
<resource methods="POST">
<inSequence>
<xslt key="LOCAL_XSLT_Validate"/>
<respond/>
</inSequence>
<outSequence/>
<faultSequence/>
</resource>
</api>
XSLT:
<?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:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fn="http://www.w3.org/2005/xpath-functions">
<xsl:template match="/">
<!-- TODO: Auto-generated template -->
<xsl:variable name="Value" select="/OperationValueRegex/Value/text()"/>
<OperationValueRegex>
<xsl:choose>
<xsl:when test="/OperationValueRegex/Value != 0">
<Result1><xsl:value-of select="fn:tokenize(/OperationValueRegex/Value, ' ')[matches(., '\d+')]"/></Result1>
</xsl:when>
</xsl:choose>
</OperationValueRegex>
</xsl:template>
</xsl:stylesheet>
</localEntry>
sample request and response Request:
{
"OperationValueRegex" : {
"Value" : "123"
}
}
Expected Result:
<OperationValueRegex>
<Result>123</Result>
</OperationValueRegex>
response when string
<OperationValueRegex>
<Result></Result>
</OperationValueRegex>
THanks