Topic
6 replies Latest Post - ‏2012-11-08T23:34:07Z by SystemAdmin
SystemAdmin
SystemAdmin
6772 Posts
ACCEPTED ANSWER

Pinned topic xslt working in stylus studio BUT not in DP xi50 4.0.2 !!!

‏2012-11-08T06:55:54Z |
I have to do xml data validation and have to loop over element called "usrPacks".

if each string has a format like a,b,c than thats good record Else its bad record and i have to reject the data.

Here is xslt

<xsl:for-each select="soapenv:Envelope/soapenv:Body/user:putUserPack/userPackReq/usrPacks">
<xsl:variable name="temp" select="."/>
<xsl:if test="count(tokenize($temp,','))&lt; 3">
<dp:reject>PS104:05,TOP Bad format userpackrecord= <xsl:value-of select="$temp"/></dp:reject>
</xsl:if>
<xsl:for-each select="tokenize($temp,',')">
<xsl:if test="string-length(.) &lt; 1">
<dp:reject>PS104:05,Bad format userpackrecord= <xsl:value-of select="$temp"/></dp:reject>
</xsl:if>
</xsl:for-each>
</xsl:for-each>


example data:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:user="http://SMOHMMLib/UserPackSize340B">
<soapenv:Header/>
<soapenv:Body>
<user:putUserPack>
<userPackReq>
<hmmMain>
<!--Optional:-->
<sessionId>123</sessionId>
<!--Optional:-->
<username>asd</username>
<!--Optional:-->
<acctId>aasd</acctId>
</hmmMain>
<!--Optional:-->
<msgRecCnt>8</msgRecCnt>
<!--1 or more repetitions:-->

<usrPacks>1,2,3</usrPacks>
<usrPacks>1,3,3</usrPacks>
<usrPacks>1,4,3</usrPacks>
<usrPacks>1,5,3</usrPacks>
<usrPacks>1,8,3</usrPacks>
<usrPacks>1,1,3</usrPacks>
<usrPacks>1,1,3</usrPacks>
<usrPacks>a,,c</usrPacks>

<origin_cd>H</origin_cd>
</userPackReq>
</user:putUserPack>
</soapenv:Body>
</soapenv:Envelope>
the expected result should be that "PS104:05,Bad format userpackrecord= a,,c"
its working as expected in Stylus studio BUT in DP iam getting this error.

"PS104:05,TOP Bad format userpackrecord= 1,2,3"
any pointers ??

thanks
Updated on 2012-11-08T23:34:07Z at 2012-11-08T23:34:07Z by SystemAdmin
  • SystemAdmin
    SystemAdmin
    6772 Posts
    ACCEPTED ANSWER

    Re: xslt working in stylus studio BUT not in DP xi50 4.0.2 !!!

    ‏2012-11-08T06:57:15Z  in response to SystemAdmin
    here are the DEBUG logs
    :38:30 ws-proxy error 44447925 error 172.17.77.241 0x00d30003 wsgw (DP004ParagonWSP): Rejected by filter; SOAP fault sent
    22:38:30 multistep error 44447925 request 172.17.77.241 0x80c00009 wsgw (DP004ParagonWSP): request DP004ParagonWSP_ValidateUserPackRequest #1 xform: 'Transforming INPUT with local:///DP004ValidateUserPackrequestToSOAPFault.xsl results stored in OUTPUT' failed: PS104:05,TOP Bad format userpackrecord= 1,2,3
    22:38:30 xslt error 44447925 request 172.17.77.241 0x80c00010 wsgw (DP004ParagonWSP): Execution of 'local:///DP004ValidateUserPackrequestToSOAPFault.xsl' aborted: PS104:05,TOP Bad format userpackrecord= 1,2,3
    22:38:30 xmlfilter debug 44447925 request 172.17.77.241 0x80c00037 wsgw (DP004ParagonWSP): Reject set (but skipped): PS104:05,TOP Bad format userpackrecord= a,9,c
    22:38:30 xmlfilter debug 44447925 request 172.17.77.241 0x80c00037 wsgw (DP004ParagonWSP): Reject set (but skipped): PS104:05,TOP Bad format userpackrecord= 1,1,3
    22:38:30 xmlfilter debug 44447925 request 172.17.77.241 0x80c00037 wsgw (DP004ParagonWSP): Reject set (but skipped): PS104:05,TOP Bad format userpackrecord= 1,1,3
    22:38:30 xmlfilter debug 44447925 request 172.17.77.241 0x80c00037 wsgw (DP004ParagonWSP): Reject set (but skipped): PS104:05,TOP Bad format userpackrecord= 1,8,3
    22:38:30 xmlfilter debug 44447925 request 172.17.77.241 0x80c00037 wsgw (DP004ParagonWSP): Reject set (but skipped): PS104:05,TOP Bad format userpackrecord= 1,5,3
    22:38:30 xmlfilter debug 44447925 request 172.17.77.241 0x80c00037 wsgw (DP004ParagonWSP): Reject set (but skipped): PS104:05,TOP Bad format userpackrecord= 1,4,3
    22:38:30 xmlfilter debug 44447925 request 172.17.77.241 0x80c00037 wsgw (DP004ParagonWSP): Reject set (but skipped): PS104:05,TOP Bad format userpackrecord= 1,3,3
    22:38:30 xmlfilter info 44447925 request 172.17.77.241 0x80c00037 wsgw (DP004ParagonWSP): Reject set: PS104:05,TOP Bad format userpackrecord= 1,2,3
    22:38:30 xslt debug 44447925 172.17.77.241 0x80a002ac xmlmgr (default): xslt Compilation Request: Found in cache (local:///DP004ValidateUserPackrequestToSOAPFault.xsl)
    • swlinn
      swlinn
      1344 Posts
      ACCEPTED ANSWER

      Re: xslt working in stylus studio BUT not in DP xi50 4.0.2 !!!

      ‏2012-11-08T13:50:31Z  in response to SystemAdmin
      In DataPower, try str:tokenize where you've specified xmlns:str="http://exslt.org/strings" in your xsl:stylesheet element.

      Regards,
      Steve
      • HermannSW
        HermannSW
        4379 Posts
        ACCEPTED ANSWER

        Re: xslt working in stylus studio BUT not in DP xi50 4.0.2 !!!

        ‏2012-11-08T22:01:54Z  in response to swlinn
        Please attach your complete stylesheet -- tokenize() is no XPath function.

        As Steve said "str:tokenize()" is an EXSLT extension function that DataPower provides.

         
        Hermann<myXsltBlog/> <myXsltTweets/>
        • SystemAdmin
          SystemAdmin
          6772 Posts
          ACCEPTED ANSWER

          Re: xslt working in stylus studio BUT not in DP xi50 4.0.2 !!!

          ‏2012-11-08T22:26:58Z  in response to HermannSW
          Hermann,

          Here is the complete style sheet.
          <?xml version='1.0' ?>
          <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:user="http://SMOHMMLib/UserPackSize340B"
          xmlns:dp="http://www.datapower.com/extensions"
          >

          <xsl:template match="/">

          <xsl:for-each select="soapenv:Envelope/soapenv:Body/user:putUserPack/userPackReq/usrPacks">
          <xsl:variable name="temp" select="."/>
          <xsl:if test="count(tokenize($temp,','))&lt; 3">
          <dp:reject>PS104:05,TOP Bad format userpackrecord= <xsl:value-of select="$temp"/></dp:reject>
          </xsl:if>
          <xsl:for-each select="tokenize($temp,',')">
          <xsl:if test="string-length(.) &lt; 1">
          <dp:reject>PS104:05,Bad format userpackrecord= <xsl:value-of select="$temp"/></dp:reject>
          </xsl:if>
          </xsl:for-each>
          </xsl:for-each>

          </xsl:template>
          thanks
          Vishnu
          • SystemAdmin
            SystemAdmin
            6772 Posts
            ACCEPTED ANSWER

            Re: xslt working in stylus studio BUT not in DP xi50 4.0.2 !!!

            ‏2012-11-08T22:41:11Z  in response to SystemAdmin
            tokenize() is an XPath 2.0 function
            (http://www.w3.org/TR/xpath-functions/#func-tokenize)
            Unfortunately XPath 2.0 isn't yet supported on DataPower.
            You'll need to use EXSLT or a recursive template to achieve the same thing on DataPower.

            Regards,
            Nick
            • SystemAdmin
              SystemAdmin
              6772 Posts
              ACCEPTED ANSWER

              Re: xslt working in stylus studio BUT not in DP xi50 4.0.2 !!!

              ‏2012-11-08T23:34:07Z  in response to SystemAdmin
              Thanks Swlinn, Hermann.

              str:tokenize() worked good.

              Hopefully DataPower is fully xslt2.0 compliant soon.