ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

create a field that can hold data from xml document in rpgle.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • create a field that can hold data from xml document in rpgle.

    Hi All,

    I have to debug a application that communicates with a java a program from rpgle via xml.

    An xml document is created in rpgle and that xml is sent to a java program for furthur processing.

    To apply a edit I need to debug this program and therefore I want to see the xml that is prepared.

    Is there a simple way to temporarily store the xml that is being created (only for debug purposes), to a local folder/library (not sure if this can be done).

    please help...

  • #2
    Re: create a field that can hold data from xml document in rpgle.

    Modify the program to store the xml into a folder as a stream file in the IFS using the Unix-type write() API.
    Alternatively you could use the Expat parser. See the Scott Klement site here.
    Philippe

    Comment


    • #3
      Re: create a field that can hold data from xml document in rpgle.

      How is the xml document created in the RPGLE? We have places where it is either built in a string variable, or where the document may exceed 65535 characters it is built using a pointer and %alloc.
      Ben

      Comment


      • #4
        Re: create a field that can hold data from xml document in rpgle.

        Thanks Ben and Mercury

        Originally posted by BenThurley View Post
        How is the xml document created in the RPGLE?
        we are using a char field (attr: 32667A) and appending the xml to this field with the use of FormatXMLRootTagBegin, FormatXMLRootTagEnd bifs.

        what I did was just before the call of java program I passed entire data from the char field that had the xml to a single field physical file. Then copied this file to PC and remaned the file extension to .xml.

        Originally posted by Mercury View Post
        Modify the program to store the xml into a folder as a stream file in the IFS
        I believe this is the easiest way, and this xml is being stored to IFS folder. But problem is that I do not have access to production IFS folders....

        Comment


        • #5
          Re: create a field that can hold data from xml document in rpgle.

          Originally posted by indraneel_n
          I do not have access to production IFS folders....
          Well if you even can't create your own folder, you may store the XML fld into a user space that you create in your program. Thereafter you can read/edit the user space using the DSPF or EDTF commands.
          E.G.
          Code:
          DSPF STMF('/QSYS.LIB/[I]MyLib[/I].LIB/[I]MyUsrSpc[/I].USRSPC')
          Philippe

          Comment


          • #6
            Re: create a field that can hold data from xml document in rpgle.

            Can you not just eval the character field in debug to see what it generates?

            EVAL charfield :c 32667
            Ben

            Comment


            • #7
              Re: create a field that can hold data from xml document in rpgle.

              Ben,
              I wasn't bold enough to ask him...
              Philippe

              Comment


              • #8
                Re: create a field that can hold data from xml document in rpgle.

                Originally posted by BenThurley View Post
                Can you not just eval the character field in debug to see what it generates?

                EVAL charfield :c 32667
                yes I tried doing that but somehow in debug eval will only shows me the data for first 1021 characters.

                so, i cannot see the entire xml file...and it ain't aesthetic as well..

                Comment


                • #9
                  Re: create a field that can hold data from xml document in rpgle.

                  Originally posted by Mercury View Post
                  Ben,
                  I wasn't bold enough to ask him...
                  I wouldn't mind

                  Comment


                  • #10
                    Re: create a field that can hold data from xml document in rpgle.

                    Originally posted by indraneel_n View Post
                    yes I tried doing that but somehow in debug eval will only shows me the data for first 1021 characters.

                    so, i cannot see the entire xml file...and it ain't aesthetic as well..
                    That's why you use the :c to specify how many bytes of data to view. You said your string was 32667 characters long so to view the whole thing just type the following on the command line in debug.

                    EVAL charfield :c 32667

                    Obviously substituting charfield for whatever your field is called. It'll work but as you say it won't look pretty. For that you'd have to copy and paste the text into a text file and reformat it.

                    The alternatives all involve writing some code to dump the XML somewhere. One of my programs has a debug mode where it renders the XML in an HTML textbox rather than submitting it to an interface. It does this because the XML is built up using a pointer so you cannot eval it in debug.
                    Ben

                    Comment


                    • #11
                      Re: create a field that can hold data from xml document in rpgle.

                      Originally posted by BenThurley View Post
                      That's why you use the :c to specify how many bytes of data to view.
                      thanks Ben, this is nice.

                      I can copy and paste the entire field to a txt file and then rename the file to .xml. when I opened it, it did show the xml correctly.

                      Comment


                      • #12
                        Re: create a field that can hold data from xml document in rpgle.

                        You're welcome.

                        Similarly you can use :x to eval the field along with it's hexadecimal value. This can be quite useful at times. It will show you the first two length bytes of a varying length field and it also reveals characters like linefeeds that don't display properly with a normal eval.
                        Ben

                        Comment

                        Working...
                        X