Integer to String Convertion in XSLT

Viewed 332

In my WSO2 ESB project , I am using xslt files for transformation. I need to manage the type of the values from the endpoint. My payload is JSON and legacy systems's payload is also JSON. I am trying to change the integer value to string value.

Tried to use script in sequence taking payload and using js but I need to manage it in xslt.

For example ;

<xsl:if test="//jsonObject/searchTerm"> <searchTerm><xsl:value-of select="//jsonObject/searchTerm"/></searchTerm> </xsl:if>

searchTerm value is an integer value from the endpoint but i need to transfer it as string to other system. Could you please advise about this issue?

2 Answers

Could you try this,

 <xsl:if test="//jsonObject/searchTerm">
   <searchTerm>@@@<xsl:value-of select="//jsonObject/searchTerm"/></searchTerm>
 </xsl:if>

Check this code:

<xsl:if test="//jsonObject/searchTerm">
   <searchTerm><xsl:value-of select="string(//jsonObject/searchTerm)"/></searchTerm>
</xsl:if>
Related