Topic
  • 5 replies
  • Latest Post - ‏2013-06-19T03:42:40Z by Miel
smashyrahul
smashyrahul
392 Posts

Pinned topic 13: Operator expected

‏2013-06-18T18:16:38Z |

I am using below stylesheet and I dont see any compilation error in this. But still DataPower is throwing " 13: Operator expected" error.

Is there anything wrong with this stylesheet?

<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:dp="http://www.datapower.com/extensions"
    extension-element-prefixes="dp"
    exclude-result-prefixes="dp">
    
    <xsl:template match='/'>
        <xsl:variable name="rc" select="normalize-space(dp:response-header('x-dp-response-code'))" />
        
        
       <xsl:choose> 
       <xsl:when test="contains ($rc,'404')">
       <dp:set-http-response-header name="'x-dp-response-code'" value="404 not found"/>
        <xsl:message dp:type="business-log" dp:priority="info">response code is 404. Hence setting response code to 404 not found</xsl:message>
       </xsl:when>
       
       <xsl:when test="contains ($rc,'403')">
       <dp:set-http-response-header name="'x-dp-response-code'" value="403 Forbidden"/>
       <xsl:message dp:type="business-log" dp:priority="info">response code is 403. Hence setting response code to 404 Forbidden</xsl:message> 
       </xsl:when>
       
       <xsl:when test="contains ($rc,'500')">
       <dp:set-http-response-header name="'x-dp-response-code'" value="500 Internal Server Error"/>
       <xsl:message dp:type="business-log" dp:priority="info">response code is 500. Hence setting response code to 500 Internal Server Error</xsl:message> 
       </xsl:when>
       
       <xsl:when test="contains ($rc,'200')">
       <dp:set-http-response-header name="'x-dp-response-code'" value="200 OK"/>
       <xsl:message dp:type="business-log" dp:priority="info">response code is 200. Hence setting response code to 200 OK</xsl:message> 
       </xsl:when>
       
       <xsl:otherwise>
       <dp:set-http-response-header name="'x-dp-response-code'" value="$rc" />
       <xsl:message dp:type="business-log" dp:priority="info">setting response code as is</xsl:message> 
       </xsl:otherwise>
       </xsl:choose>
        
        
    </xsl:template>
    
</xsl:stylesheet>

Regards,
Rahul
  • kenhygh
    kenhygh
    1569 Posts
    ACCEPTED ANSWER

    Re: 13: Operator expected

    ‏2013-06-18T18:23:05Z  

    Rahul,

    Usually, DataPower tells you the line number of the problem.

  • kenhygh
    kenhygh
    1569 Posts

    Re: 13: Operator expected

    ‏2013-06-18T18:23:05Z  

    Rahul,

    Usually, DataPower tells you the line number of the problem.

  • smashyrahul
    smashyrahul
    392 Posts

    Re: 13: Operator expected

    ‏2013-06-18T18:25:22Z  
    • kenhygh
    • ‏2013-06-18T18:23:05Z

    Rahul,

    Usually, DataPower tells you the line number of the problem.

    Yes, But I tried to find the compilation error in this stylesheet, but couldn't find out any.

    Regards,

    Rahul

  • smashyrahul
    smashyrahul
    392 Posts

    Re: 13: Operator expected

    ‏2013-06-18T18:35:38Z  
    • kenhygh
    • ‏2013-06-18T18:23:05Z

    Rahul,

    Usually, DataPower tells you the line number of the problem.

    The compilation error is gone. But this stylesheet is not working as the way I am expecting it to.

    Regards,

    Rahul

  • swlinn
    swlinn
    1348 Posts

    Re: 13: Operator expected

    ‏2013-06-18T19:33:10Z  

    The compilation error is gone. But this stylesheet is not working as the way I am expecting it to.

    Regards,

    Rahul

    Rahul,

    So how is it misbehaving?

    Regards,

    Steve

  • smashyrahul
    smashyrahul
    392 Posts

    Re: 13: Operator expected

    ‏2013-06-18T19:51:41Z  
    • swlinn
    • ‏2013-06-18T19:33:10Z

    Rahul,

    So how is it misbehaving?

    Regards,

    Steve

    Hello Steve,

    I am not getting this error now. ( 13:Operator expected) it was offcourse the compilation error, which I had corrected, this stylesheet is getting executed now. But as mentioned in the other post, it is not able to convert the '404 processed' or '403 processed' http response to '404 not found' or '403 forbidden' respectively.

    below is the correct xslt which doesn't give this compilation error.

    <xsl:stylesheet version="1.0"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        xmlns:dp="http://www.datapower.com/extensions"
        extension-element-prefixes="dp"
        exclude-result-prefixes="dp">
        
        <xsl:template match='/'>
            <xsl:variable name="rc" select="normalize-space(dp:response-header('x-dp-response-code'))" />
            
            
            <xsl:message dp:type="business-log" dp:priority="info">Backend HTTP status = <xsl:value-of select="$rc" /></xsl:message>
            
            
           <xsl:choose>
           <xsl:when test="contains ($rc,'404')">
           <dp:set-http-response-header name="'x-dp-response-code'" value="'404 not found'"/>
            <xsl:message dp:type="business-log" dp:priority="info">response code is 404. Hence setting response code to 404 not found</xsl:message>
           </xsl:when>
           
           <xsl:when test="contains ($rc,'403')">
           <dp:set-http-response-header name="'x-dp-response-code'" value="'403 Forbidden'"/>
           <xsl:message dp:type="business-log" dp:priority="info">response code is 403. Hence setting response code to 403 Forbidden</xsl:message>
           </xsl:when>
           
           <xsl:when test="contains ($rc,'500')">
           <dp:set-http-response-header name="'x-dp-response-code'" value="'500 Internal Server Error'"/>
           <xsl:message dp:type="business-log" dp:priority="info">response code is 500. Hence setting response code to 500 Internal Server Error</xsl:message>
           </xsl:when>
           
           <xsl:when test="contains ($rc,'200')">
           <dp:set-http-response-header name="'x-dp-response-code'" value="'200 OK'"/>
           <xsl:message dp:type="business-log" dp:priority="info">response code is 200. Hence setting response code to 200 OK</xsl:message>
           </xsl:when>
           
           <xsl:otherwise>
           <dp:set-http-response-header name="'x-dp-response-code'" value="$rc" />
           <xsl:message dp:type="business-log" dp:priority="info">setting response code as is</xsl:message>
           </xsl:otherwise>
           </xsl:choose>
            
            
        </xsl:template>
        
         
        
    </xsl:stylesheet>





    Regards,

    Rahul