Search code examples
xmlxslt-1.0ibm-datapower

Greater than(>) and less than(<) operator not working in XSLT


Below is my XSL where I am trying to check the condition if size of the file is greater then the preset value and try to stop the processing, but it looks like the condition is not getting executed. I am not sure if it is not formatted right way. Can anyone look in to it and see if there is any issue?

Value of both the variable IncomingFileSize and SetFileSize are of type 'number'

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:dp="http://www.datapower.com/extensions" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:dpconfig="http://www.datapower.com/param/config" extension-element-prefixes="dp" exclude-result-prefixes="dp dpconfig inc">
<xsl:template match="/">
    <xsl:variable name="File_CD" select="document('local:///FileIntake/Resources/FileServiceConfigData.xml')"/>
    <xsl:variable name="IncomingFileSize" select="number(dp:variable('var://service/mpgw/request-size'))"/>
    <!-- <xsl:variable name="SetFileSize" select="$File_CD/FileServiceConfig/FileSize"/> -->
    <xsl:variable name="SetFileSize" select="number($File_CD/FileServiceConfig/FileSize)"/>
    <dp:set-variable name="'var://context/var/IncomingFileSize'" value="$IncomingFileSize"/>
    <dp:set-variable name="'var://context/var/SetFileSize'" value="$SetFileSize"/>
    <xsl:choose>
        <xsl:when test="'$IncomingFileSize '&gt;' $SetFileSize'">
            <dp:reject/>
        </xsl:when>
        <xsl:otherwise>
            <dp:accept/>
        </xsl:otherwise>
    </xsl:choose>
</xsl:template>


Solution

  • I figured out where I went wrong. Below is the correct way to write the condition. I had put unnecessary single quotes.

    <xsl:when test="$IncomingFileSize &gt; $SetFileSize">