RPG program: XML command error

45 pts.
Tags:
CCSID
RPG
XML
I received an XML-document via mail, I detached it and placed it into the IFS. Then I wrote an RPG-program where I used the XML-INTO command to read the XML-document. But, when I run my program I always get the error "The XML parser detected error code 302" I think there's something wrong with the CCSID, the IFS-file is in CCSID 1252 Who can help me with this? Thanks!

Answer Wiki

Thanks. We'll let you know when a new response is added.

It would be helpful if you could:

  1. Tell us what options you have specified for the %XML built-in
  2. Tell us what values are stored in the initial record of the XML document. Using the DSPF command and the XML document, use F10 to view the hex values and then paste the first few records here. An example would be:
<pre>
405C5C5C 5C5C5C5C 5C5C5C5C 5CC28587 89959589 ************Beginni
3C3F786D 6C207665 7273696F 6E3D2231 2E302220 <?xml version="1.0"
3C21444F 43545950 45205163 64434C43 6D64205B <!DOCTYPE QcdCLCmd [
200A
</pre>

This will help determine if the IFS CCSID tag is really messed up (for instance the data is really EBCDIC or somesuch).

Answers to the above might help us determine what is wrong, or might simply prompt additional questions…

Bruce Vining

Discuss This Question: 7  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Guygeb
    1) my XML-INTO statement D XML_Source S 256a varying D Inz('/home/ecn0010.xml') /free XML-INTO ECN %XML(XML_source : 'doc=file allowmissing=yes case=any'); 2) values 405C5C5C 5C5C5C5C 5C5C5C5C 5CC28587 89959589 ************Beginni 3C45434E 3E0D0A 3C73626C 5F45434E 3E0D0A 20203C45 434E3E45 43313639 20202020 203C2F45 EC169 BUNKOVSKY 20203C4C 6F63616C 43757374 6F6D6572 4E756D62 0010 20203C54 696D6553 74616D70 3E323030 382D3031 2008-01
    45 pointsBadges:
    report
  • bvining
    Here is a RPG program that appears to work:
    h dftactgrp(*no)                                                      
                                                                          
    dsbl_ECN          ds                  qualified                       
    d                                     dim(10)                         
    d ECN                           50                                    
    d ECNName                       50                                    
    d LocalCustomerNumber...                                              
    d                               50                                    
    d Company                       50                                    
    dTimeStamp                      50                                    
                                                                          
    dPSDS            sds           429    qualified                       
    d XMLEntries            372    379i 0                                 
                                                                          
    dXMLFile          s             20    inz('/xml3.txt')                
    d                                     varying                         
    dOptions          s             50    inz('doc=file case=any -         
    d                                     path=ECN/sbl_ECN')               
                                                                           
     /free                                                                 
      xml-into sbl_ECN %xml(XMLFile :Options);                             
      dsply ('There were ' + %char(PSDS.XMLEntries) + ' entries found.');  
      *inlr = *on;                                                         
      return;                                                              
     /end-free                                                             
    
    For my testing I created an IFS stream file, CCSID tagged 1252, with the following:
    <ECN>                                                        
    <sbl_ECN>                                                    
    <ECN>EC169    </ECN>                                         
    <ECNName>BUNDOVSKY                           </ECNName>      
    <LocalCustomerNumber>  00481      </LocalCustomerNumber>     
    <Company>0010    </Company>                                  
    <TimeStamp>2008-01-16T09:39:17.843</TimeStamp>               
    </sbl_ECN>                                                   
    <sbl_ECN>                                                    
    <ECN>EC13     </ECN>                                         
    <ECNName>Company A                           </ECNName>      
    <LocalCustomerNumber>  00481      </LocalCustomerNumber>     
    <Company>0010    </Company>                                  
    <TimeStamp>2008-01-16T09:39:17.843</TimeStamp>               
    </sbl_ECN>                                               
    <sbl_ECN>                                                
    <ECN>EC1313   </ECN>                                     
    <ECNName>Company B                           </ECNName>  
    <LocalCustomerNumber>  00481      </LocalCustomerNumber> 
    <Company>0010    </Company>                              
    <TimeStamp>2008-01-16T09:39:17.843</TimeStamp>           
    </sbl_ECN>                                               
    </ECN>                                                   
    
    Running the RPG program resulted in the first three elements of sbl_ECN being populated with the expected results, and the variable PSDS.XMLEntries set to a value of 3. I hope this helps, Bruce Vining http://www.brucevining.com/
    6,485 pointsBadges:
    report
  • Guygeb
    Your program helped me a lot, thanks Still i got a CCSID issue with it The problem is that the XML-document comes from our company in Russia and so, contains Russian Characters (for example <LocalCustomerNumber>Кл00481</LocalCustomerNumber> ) when i run my program i still get the parser error
    45 pointsBadges:
    report
  • bvining
    This additional information certainly does help! Somewhere the system is being told that the data is in CCSID 1252. This is wrong. CCSID 1252 corresponds to Windows Latin 1, essentially Western European languages, and this CCSID does not contain the Cyrillic characters you are receiving. Now the question becomes what CCSID is being sent to you. I suspect the data is in UTF8 (CCSID 1208) but cannot be sure. I do know that if it was in CCSID 1251 (Windows Cyrillic) that my sample program works without a CCSID error, but you also end up with the Cyrillic К being converted (incorrectly due to the CCSID mis-identification) to the Latin 1 Ê. As your previous pasting of the file in hex didn't include the LocalCustomerNumber can you paste that particular entry in its entirety? That will help determine what CCSID is in use. Or better, ask whoever is sending you the document what it is :-) But the good news is we know it's not a problem with XML-INTO! The big question now though is what you want to do with these Cyrillic values. If you need to store them (and characters from other languages) in your databases then you have some design issues to work through -- issues that are larger than I would feel comfortable trying to tackle in this forum. Bruce Vining http://www.brucevining.com/
    6,485 pointsBadges:
    report
  • bvining
    As an update, Guygeb sent me offline a LocalCustomerNumber entry. The value was:
    x'D09AD0BB3030343831'
    
    where the initial 4 bytes (x'D09AD0BB') are the Cyrillic characters 'Кл' encoded with UTF8. With this entry I was easily able to recreate the 302 failure :-) To correct the situation I: 1. Used the Change Attribute command CHGATR to change the *CCSID value of the stream file to 1208 (the CCSID for UTF8). 2. Changed the RPG program above to define LocalCustomerNumber as a UCS2 field:
    d LocalCustomerNumber...                          
    d                               50c   ccsid(13488)
    
    With these changes the program then correctly processed the XML file. The RPG LocalCustomerNumber variable was set to x'041A043B' in the intial four bytes of the field. x'041A043B' is the UCS2 value for the Cyrillic character string 'Кл'. Bruce Vining http://www.brucevining.com/
    6,485 pointsBadges:
    report
  • Guygeb
    Hey, i tested your latest remarks and it works just fine (of course) in my program there's a dim(32767) to tell RPG how many records (customers) are expected what if there are more dan 32767 customers ? Dsbl_ECN DS qualified D dim(32767) D ECN 5a D ECNName 25a
    45 pointsBadges:
    report
  • bvining
    If you anticipate that there may be more entries than will fit into an array then you should consider using the %HANDLER option of XML-INTO. This way XML-INTO would call your function each time the array becomes full and once, at the end, for a partical array. Bruce Vining http://www.brucevining.com/
    6,485 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following