[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Query on http_parse_xml_string



   Hello Scott,

   Thanks a ton :-) That solved my problem. Appreciate all your help.

   Have a great weekend!

   Regards,

   Abhijit

   On Fri, Jan 13, 2012 at 10:30 AM, Scott Klement
   <[1]sk@xxxxxxxxxxxxxxxx> wrote:

     Hello Abhijit,
     Here's the reason why you get the error:
       exec sql values upper(trim(:DataIn)) into :xmlData;
     See that upper() function?  It converts the data to uppercase.
     XML is a case-sensitive environment. While &amp; is a predefined and
     well-known entity, &AMP; is not. In XML uppercase is not treated as
     the same thing as lowercase.

   On 1/12/2012 7:37 PM, Abhijit Fulambrikar wrote:

   Hi Scott,
   Thank you so much for your help. I took your program and it works great
   on my system as well.
   The parser is able to parse the special characters.
   Now the difference in my program is that the variable DataIn is
   declared
   as sqltype(clob:4096000).
   Also my program accepts the DataIn as an input parameter.
   I have broken your program in two programs and made it similar to my
   program with string as clob type.
   I am able to replicate the issue.
   Attaching the programs below. You should be able to replicate it on
   your
   system.
   Actually we had declares a variable as clob in copy book and later all
   other variables declared
   in program are referencing the same definition (LikeDS). We did this
   because it would be easy to change the type of the variable if
   required.
   Thank you,
   Abhijit
   On Thu, Jan 12, 2012 at 2:35 PM, Scott Klement <[2]sk@xxxxxxxxxxxxxxxx

   <mailto:[3]sk@xxxxxxxxxxxxxxxx>> wrote:
      Hi Abhijit,
      Please understand this:  In order to help you, we need enough
      information to reproduce the problem.
      I've spent a considerable amount of time (more than an hour) trying
      to reproduce your problem, but I just can't get it to fail as you
      describe.  I need to know what you're doing that makes it fail.
      Here's what I'd like to do:
      1) I'll attach the source code for my "test" program to this
      message. My program is a complete program that you can load/run on
      your system (just copy/paste it to a source member and compile it.)
      2) I need you to reply to this message, and do me the same courtesy.
      Attach a complete program (preferably, by modifying mine) that I can
      copy/paste to a source member, compile and run.  Your copy should
      reproduce the Expat error that you described.
      Thanks!
      On 1/12/2012 10:33 AM, Abhijit Fulambrikar wrote:
              Thanks Alan.
              This is how I am creating the test data in the SQLRPG
   program.
              exec sql
                values '<PopulateComments>  +

            <ServiceRequest>406725</__ServiceRequest>  +

          <Comment>  +
          <Line>1</Line>  +

            <CreateDate>20111227</__CreateDate>  +
            <CreateTime>145232</__CreateTime>  +

          <Type>CAUSE</Type>  +
          <Text>Engine oil leak&amp; test</Text>  +
          </Comment>  +
          <Comment>  +
          <Line>2</Line>  +

            <CreateDate>20111227</__CreateDate>  +
            <CreateTime>145232</__CreateTime>  +

          <Type>CORRECTION</Type>  +
          <Text>Replace engine oil and other parts</Text>  +
          </Comment>  +
          </PopulateComments>' into :DataIn;
              Input data
              XMLDATA.@XMLDATA_DATA =


     ....5...10...15...20...25...__30...35...40...45...50...55...__60
                     1 '<POPULATECOMMENTS>
            <SERVICEREQUEST>406725</__SERVICEREQUEST> <'

                  61 'COMMENT> <LINE>1</LINE>

            <CREATEDATE>20111227</__CREATEDATE> <C'

                 121 'REATETIME>145232</CREATETIME> <TYPE>CAUSE</TYPE>
          <TEXT>ENGIN'
                 181 'E OIL LEAK&AMP; TEST</TEXT> </COMMENT> <COMMENT>
          <LINE>2</L'

                   241 'INE> <CREATEDATE>20111227</__CREATEDATE>

          <CREATETIME>145232</C'
                 301 'REATETIME> <TYPE>CORRECTION</TYPE> <TEXT>REPLACE
          ENGINE OIL '
                 361 'AND OTHER PARTS</TEXT> </COMMENT>
   </POPULATECOMMENTS> '
                 421 ' '
              Error
               DATAOUT.@XMLDATA_DATA =


     ....5...10...15...20...25...__30...35...40...45...50...55...__60
                      1 '<?xml
     version="1.0"?><__POPULATECOMMENTS><Error>XML

          parse
              fail'
                   61 'ed at line 1, col 191: undefined
              entity</Error></POPULATECOM'
                  121 'MENTS>
          '
                  181 '
          '
                  241 '
          '
              When I change the Input Data and put&  instead of "&amp;" ,
          below
              error is returned
              DATAOUT.@XMLDATA_DATA =


     ....5...10...15...20...25...__30...35...40...45...50...55...__60
                     1 '<?xml
     version="1.0"?><__POPULATECOMMENTS><Error>XML

          parse fail'
                  61 'ed at line 1, col 192: not well-formed (invalid
          token)</Erro'
                 121 'r></POPULATECOMMENTS> '
              Is the function "http_parse_xml_string" capable of handling
          the special
              characters.
              Thanks for your help.
              Thanks&  Regards,
              Abhijit
              On Wed, Jan 11, 2012 at 6:11 PM, Alan

            Campin<[1][4]alan0307d@xxxxxxxxx
     <mailto:[5]alan0307d@xxxxxxxxx>>

              wrote:
                  The&amp is the same as putting an&  in the xml because&
    are
                special
                  characters I believe. The problem is that I don't think
          the EXPAT
                  parser that Scott uses recognizes the&  special strings
   like
          &quot,
                  etc.
                  When I dealt with problem it put the xml to a stream
          file and used
                  XML-SAX to parse it and that recognized the special
          characters. I
                think
                  this may be occurring because you have an xml file
          embedded inside
                the
                  main file so you have to extract the files from inside
          and then
                parse
                  it separately. This is not a problem if the resulting
          file is
                  relatively small. It gets trickee if the file embedded
          inside is
                very
                  big and won't fit in a variable. Then you need to write
   to a
                stream
                  file.
                  Would need to see the entire XML.
                On Wed, Jan 11, 2012 at 4:24 PM, Abhijit Fulambrikar

            <[1][2]abhijit.fulambrikar@__[6]gmail.com
            <mailto:[7]abhijit.fulambrikar@xxxxxxxxx>>  wrote:

                    Hi,
                    I have a question regarding the parsing of special
          character's in
                  XML.
                    I am using "http_parse_xml_string" to parse the XML
          string.
              Please
                  see
                    the
                    code below
                    xmlError =

            http_parse_xml_string(%addr(__xmlData.@xmlData_Data):

                      xmlData.@xmlData_Len: 0: *null: xmlHandler: *null)<>
    0;
                    if xmlError;
                      xmlAddRootAndElement(Process: ERROR: http_error());
                    endif;
                    The XML data which I am sending has the below tag
          which has
                  special
                    character "&". The character is formatted as"&amp;" as
          shown
                  below
          <Text>Replace engine oil&amp; other parts</Text>
                    The error which is returned from http_parse_xml_string
          is as
              below
                    XML parse failed at line 1, col 349: undefined entity
                    When I tried with the below data
          <Text>Replace engine oil&  other parts</Text>
                    I get the error as
                    XML parse failed at line 1, col 350: not well-formed
          (invalid
                  token)
                    Please let me know if I am following some incorrect
          process.
                  Thanks for
                    your help.
                    Regards,
                    Abhijit


     ------------------------------__------------------------------__----
     ----

                    ---
                    This is the FTPAPI mailing list.  To unsubscribe,
          please go to:


     [2][3][8]http://www.scottklement.__com/mailman/listinfo/ftpapi
            <[9]http://www.scottklement.com/mailman/listinfo/ftpapi>

     ------------------------------__------------------------------__----
     ----
                      ---
                  References
                    1. mailto:[4]abhijit.fulambrikar@__[10]gmail.com
            <mailto:[11]abhijit.fulambrikar@xxxxxxxxx>
                    2.
            [5][12]http://www.scottklement.__com/mailman/listinfo/ftpapi
            <[13]http://www.scottklement.com/mailman/listinfo/ftpapi>

     ------------------------------__------------------------------__----
     ----

                ---
                This is the FTPAPI mailing list.  To unsubscribe, please
          go to:


     [6][14]http://www.scottklement.__com/mailman/listinfo/ftpapi
            <[15]http://www.scottklement.com/mailman/listinfo/ftpapi>

     ------------------------------__------------------------------__----
     ----
                  ---
            References
                1. mailto:[16]alan0307d@xxxxxxxxx
     <mailto:[17]alan0307d@xxxxxxxxx>
                2. mailto:[18]abhijit.fulambrikar@__[19]gmail.com
            <mailto:[20]abhijit.fulambrikar@xxxxxxxxx>
                3.
     [21]http://www.scottklement.com/__mailman/listinfo/ftpapi
            <[22]http://www.scottklement.com/mailman/listinfo/ftpapi>
                4. mailto:[23]abhijit.fulambrikar@__[24]gmail.com
            <mailto:[25]abhijit.fulambrikar@xxxxxxxxx>
                5.
     [26]http://www.scottklement.com/__mailman/listinfo/ftpapi
            <[27]http://www.scottklement.com/mailman/listinfo/ftpapi>
                6.
     [28]http://www.scottklement.com/__mailman/listinfo/ftpapi
            <[29]http://www.scottklement.com/mailman/listinfo/ftpapi>

     ------------------------------__------------------------------__----
     -------

          This is the FTPAPI mailing list.  To unsubscribe, please go to:

            [30]http://www.scottklement.com/__mailman/listinfo/ftpapi
            <[31]http://www.scottklement.com/mailman/listinfo/ftpapi>

     ------------------------------__------------------------------__----
     -------


   -----------------------------------------------------------------------
      This is the FTPAPI mailing list.  To unsubscribe, please go to:
      [32]http://www.scottklement.com/mailman/listinfo/ftpapi

   -----------------------------------------------------------------------

References

   1. mailto:sk@xxxxxxxxxxxxxxxx
   2. mailto:sk@xxxxxxxxxxxxxxxx
   3. mailto:sk@xxxxxxxxxxxxxxxx
   4. mailto:alan0307d@xxxxxxxxx
   5. mailto:alan0307d@xxxxxxxxx
   6. http://gmail.com/
   7. mailto:abhijit.fulambrikar@xxxxxxxxx
   8. http://www.scottklement/
   9. http://www.scottklement.com/mailman/listinfo/ftpapi
  10. http://gmail.com/
  11. mailto:abhijit.fulambrikar@xxxxxxxxx
  12. http://www.scottklement/
  13. http://www.scottklement.com/mailman/listinfo/ftpapi
  14. http://www.scottklement/
  15. http://www.scottklement.com/mailman/listinfo/ftpapi
  16. mailto:alan0307d@xxxxxxxxx
  17. mailto:alan0307d@xxxxxxxxx
  18. mailto:abhijit.fulambrikar@
  19. http://gmail.com/
  20. mailto:abhijit.fulambrikar@xxxxxxxxx
  21. http://www.scottklement.com/__mailman/listinfo/ftpapi
  22. http://www.scottklement.com/mailman/listinfo/ftpapi
  23. mailto:abhijit.fulambrikar@
  24. http://gmail.com/
  25. mailto:abhijit.fulambrikar@xxxxxxxxx
  26. http://www.scottklement.com/__mailman/listinfo/ftpapi
  27. http://www.scottklement.com/mailman/listinfo/ftpapi
  28. http://www.scottklement.com/__mailman/listinfo/ftpapi
  29. http://www.scottklement.com/mailman/listinfo/ftpapi
  30. http://www.scottklement.com/__mailman/listinfo/ftpapi
  31. http://www.scottklement.com/mailman/listinfo/ftpapi
  32. http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------
This is the FTPAPI mailing list.  To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------