Limitations of the XML Parser

  • An RPG character variable can only be 16773104 bytes long. If your program has a pointer to XML data that is longer than that, for example from an MQSeries®® call, you will have to write the XML data to a temporary file in the Integrated File System, and parse the XML data from your temporary file. See Figure 1 for a sample procedure that does this.
  • If the parsing is done in a single-byte character CCSID, the maximum number of characters that the parser can handle is 2147483408.
  • If the parsing is done in UCS-2, the maximum number of UCS-2 characters that the parser can handle is 1073741704.
  • The parser does not support every CCSID. If your job CCSID is one of the CCSIDs that the parser does not handle, you must parse your document in UCS-2.
    • The following EBCDIC CCSIDs are supported: 1047, 37, 1140, 273, 1141, 277, 1142, 278, 1143, 280, 1144, 284, 1145, 285, 1146, 297, 1147, 500, 1148, 871, and 1149.
    • The following ASCII CCSIDs are supported: 819, 813, 920.
    • The following Unicode CCSIDs are supported: 1200, 13488, 17584.
  • The parser does not support entity references other than the five predefined references &, &apos, &gt, &lt, and &quot. When it encounters an unknown entity reference, it generates either an "unknown reference" or "unknown attribute reference" event. The value of the event is the reference in the form "&name;".
  • The parser does not parse the DOCTYPE declaration. The text of the DOCTYPE declaration is passed as the data value for the "DOCTYPE declaration" event.
  • The parser does not support name spaces. It ignores the colons in XML element and attribute names.
  • The parser does not generate "start prefix mapping" and "end prefix mapping" events. It ignores the colons in XML element and attribute names.
Figure 1. Writing data to an Integrated File System file
 * Parameters:
 * 1. path      : a pointer to a null-terminated string containing
 *                the path to the file to be written
 * 2. dataPtr   : a pointer to the data to be written
 * 3. dataLen   : the length of the data in bytes
 * 4. dataCcsid : the CCSID of the data
 * 5. fileCcsid : the desired CCSID of the file
 * Sample RPG coding:
 *   ifsWrite ('/home/mydir/temp.xml' : xmlPtr : xmlLen : 37 : 37);
 *   xml-into ds %xml('/home/mydir/temp.xml' : 'doc=file');
 * To delete the file, use the system command
 *   rmvlnk '/home/mydir/temp.xml'
 * Note: This module requires BNDDIR(QC2LE)
 P ifsWrite        B                   EXPORT
D ifsWrite        PI
D  path                           *   VALUE OPTIONS(*STRING)
D  dataPtr                        *   VALUE
D  dataLen                      10I 0 VALUE
D  dataCcsid                    10I 0 VALUE
D  fileCcsid                    10I 0 VALUE

D O_CREAT         C                   x'00000008'
D O_TRUNC         C                   x'00000040'
D O_WRONLY        C                   x'00000002'
D O_RDWR          C                   x'00000004'
D O_CCSID         C                   x'00000020'
D O_TEXT_CREAT    C                   x'02000000'
D O_TEXTDATA      C                   x'01000000'
D O_SHARE_NONE    C                   x'00080000'

D S_IRUSR         C                   x'0100'
D S_IROTH         C                   x'0004'
D S_IRGRP         C                   x'0020'
D S_IWUSR         C                   x'0080'
D S_IWOTH         C                   x'0002'

   

D ssize_t         S             10I 0
D size_t          S             10U 0

D open            PR            10I 0 EXTPROC('open')
D   path                          *   VALUE OPTIONS(*STRING)
D   flag                        10I 0 VALUE
D   mode                        10I 0 VALUE
D   fileCcsid                   10I 0 VALUE options(*nopass)
D   dataCcsid                   10I 0 VALUE options(*nopass)
D writeFile       PR                  LIKE(ssize_t)
D                                     EXTPROC('write')
D   handle                      10I 0 VALUE
D   data                          *   VALUE
D   len                               VALUE LIKE(size_t)
D closeFile       PR            10I 0 EXTPROC('close')
D   handle                      10I 0 VALUE

D oflag           S             10I 0
D omode           S             10I 0
D handle          S             10I 0
D rc              S             10I 0

D sysErrno        PR              *   EXTPROC('__errno')
D errno           S             10I 0 BASED(pErrno)
 /FREE
   pErrno = sysErrno();
   oflag = 0 + O_WRONLY + O_CREAT + O_TEXT_CREAT + O_TRUNC
         + O_CCSID + O_TEXTDATA + O_SHARE_NONE;
   omode = 0 + S_IRUSR + S_IWUSR + S_IRGRP + S_IROTH;

   handle = open(path : oflag : omode : fileCcsid : dataCcsid);
// insert error handling if handle is less than zero
   
   rc = writeFile (handle : dataPtr : dataLen);
   // insert error handling if rc is not zero
   
   rc = closeFile (handle);
   // insert error handling if rc is not zero
   
 /END-FREE
P ifswrite        E