ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

XML File with C API in RPGLE

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

  • XML File with C API in RPGLE

    Hi,

    I have implemented a program who generate XML files directly in the IFS, with C API's and after I tried to transfer the files to a Windows folder with the help of QSH - I already have a CLLE program who make this job, I handled the name for the xml file and the path but after the transfer I can't see the xml file - I have a problem with encoding of data and I don't know what is the problem.
    In the IFS I can see the streamfile properly and I don't know if I have a problem with the file ccsid or what is the problem, please help me, attached a printscreen with the output file on windows.


  • #2
    This is how I see the source of my XML file on Windows:
    Lo§??@¥??¢???~ñKð@??ƒ?????~äãÆ`øon
    %LÓ?£Ã??@å??¢???~ññò@Å????×???¤ƒ£?¤?~¢?????ƒ?D? ??ƒ??Kƒ??@Õ??×???¤ƒ£?¤?~ÔÅÙÃÅÙ@âÁâ@Ã???×???¤ƒ£? ¤?~ÄÔÅÙðñ@Ä?£?ã???Ç?????£???~òðñö`ðø`ðùãòòzõózô ô@É?~ÁÙòðñöðøðùðððn
    %LÆ?ƒ????@Ä?£?È?¤??Ù?ƒ??£???ÄÅÓÅÇ~òðñöðöðòðöñôðð @Ã???Å?¥??~ðñ@å??¢???Õ????~×ðòåðñ@ã¨??Å?¥??~ð ñ@Õ??Å??££?¤?~ÄÅÓÁÂÓÉ@`@ÄÅÓ×ÉÅÙÙÅ@Â@âÉÅÇÅ@â???£ Å??££?¤?~óðøôôøøõñððñôô@Ä?£?È?¤??Ù?ƒ??£???Ä??~ò ðñöðöðññùñùðñ@×???£Ä???£~ðñ@ã¨?ÃÙÔ~ñ@É?Å?¥??~ Áø££ó¥æÂÆÁ?÷?õÙ¦ÂÒô×???@å??¢???ÃÙÔ~ññò@§¢?z??Õ ???¢??ƒ?âƒ????Ó?


    If I try to open with Chrome I have error regarding encoding: This page contains the following errors:

    error on line 1 at column 1: Document is empty error on line 1 at column 1: Encoding error
    Below is a rendering of the page up to the first error.

    Comment


    • #3
      How do you create the XML document? Pure Text, with (embedded) SQL?
      What is the CCSID for the XML-Document and the IFS file?

      I assume CCSID conversion is not performed (correctly)

      Birgitta

      Comment


      • #4
        I create the XML document with C API's - open, write and close - I created directly a streamfile in IFS with the structure of an XML file and the extension .xml - with the tags <?xml version="1.0" encoding="UTF-8"?> & the rest of tags, so, not with SQL, not notion of CLOB.

        For creation and open I used the statement: open(%trim(my_ifs_path): O_CREAT + O_TRUNC + O_WRONLY: (6*64) + (6*8) + (4)); -- I don't have a very large knowledge about this side, I understood I have to used this flags. If it something wrong tell me please, I need to have the encoding UTF-8 in the XML files.

        Curiously, if I make the transfer with FTP, from command prompt from my station & connecting to AS400, I can have the XML file in a properly format -> I can open in a browser and everything it is all right.
        I have the correct tags:
        <?xml version="1.0" encoding="UTF-8"?> etc..

        I have a problem in the program who made the transfer with QSH - again, I didn't have used before, again, QSH it is a new concept for me.. only with the transfer with QSH in a windows folder I have the wrong file, with issues of data encoding, like:
        Lo§??@¥??¢???~ñKð@??ƒ?????~äãÆ`øon
        %LÓ?£Ã??@å??¢???~ññò@Å????×???¤ƒ£?¤?~¢?????ƒ?D? ??ƒ??Kƒ??@Õ??×???¤ƒ£?¤?~ÔÅÙÃÅÙ@âÁâ@Ã???×???¤ƒ£? ¤?~ÄÔÅÙðñ@Ä?£?ã???

        Comment


        • #5
          You aren't telling the system how the data is encoded, and you're not telling it to translate it for you, so how would it know that the data is in UTF-8? (Are you even putting it in UTF-8?)

          Comment


          • #6
            Originally posted by voicucosmin90 View Post
            I have a problem in the program who made the transfer with QSH...‰”…
            What "program"? What do you mean that you "made the transfer with QSH"?

            That sounds like you create the file somewhere in the server, and then either use FTP to receive that file on your PC or use QSH to copy the file to a shared directory to pick up with your PC. Can you clarify the exact process that and that doesn't? Especially show any commands that you use.
            Tom

            There are only two hard things in Computer Science: cache invalidation, naming things and off-by-one errors.

            Why is it that all of the instruments seeking intelligent life in the universe are pointed away from Earth?

            Comment


            • #7
              I want to say QSHELL but it is used also a command in the program already existent for transfer, command LNCCMD - it is a part of Launcher400, a tool who is installed.
              I think I found the problem, I tried to make the transfer with LNCXFER command - from Launcher400 - and I saw that I have CCSID - 00297 Job CCSID: 00297 - I saw this thing with F15 on the streamfile, wrklnk in my directory in IFS
              If I change the CCSID to 819 the things goes well and I can retrieve the xml file in a properly format - I don't know why with the FTP it was good, probably it makes the translation and all the things.

              For change the CCSID I used CPY command with the new CCSID=819 but with this command I created a new streamfile in my directory from IFS - is there any other options to change or to set the CCSID to 819?

              Comment


              • #8
                As Scott has already mentioned, you're not telling the system how the data is encoded or how to translate it.
                The Open() API has the following parameters:
                path
                oflag
                mode
                conversion ID
                text file creation conversion ID

                You probably should specify the O_CCSID flag and a ccsid value in the conversion ID. I don't use the STMF APIs much so you should check the infocentre for info on the API.

                Comment

                Working...
                X