RXS_parse()

Call this subprocedure to parse either an XML document residing in the IFS or the contents of an RPG variable that contains XML.

Note: Sending to standard out (using RXS_STDOUT for pOutType) when offering a web service generally executes faster because it does not need to go to an IFS stream file first. Using RXS_VAR for pOutType will also execute slightly faster when executing a web service on a remote machine because it does not need to go to an IFS stream file.

Ordinarily you will set up or “register” handler pointers using one or all of the following subprocedures before calling RXS_parse():

The RXS_parse() function will run even if you do not register any handlers. However, if you do not specify any handlers, the parser will only notify the program when it finds XML errors. It will not return notice of any other events.

Every locally defined subprocedure registered with the parser as an event handler must have the four parameters listed in the following example:

  
D Handler         pi
D  pType                              value like(RXS_Type)
D  pXPath                             value like(RXS_XPath)
D  pData                              value like(RXS_XmlData)
D  pDataLen                           value like(RXS_Length)
  

Subprocedure Prototype

D RXS_parse       pr            10i 0

Used to parse XML. Returns a 4-byte integer. The return value will be 0 unless RXS_parseQuit() is invoked during parsing and a non-zero value is passed to the subprocedure.

D  pFilePathOrData...
D                                     value like(RXS_XmlData)

Used to specify a file in the IFS or actual XML residing in an RPG variable. If an IFS file is specified it must either be fully qualified (i.e. /home/user/mydoc.xml) or must reside in the default transaction directory (i.e. /www/rxs/trans.) If it resides in the default transaction directory then you can just specify it as 'mydoc.xml.'

D  pType                              value like(RXS_Type)

Use RXS_STMF if the value passed in pFilePathOrData is a path to an IFS file. Use RXS_VAR if the value passed in pFilePathOrData contains XML.

Valid Values:

  • RXS_STMF
  • RXS_VAR

D  pErrProcPtr                    *   procptr value

This parameter tells the XML parser which procedure in your program to call if the parser encounters an error. It is of type PROCPTR and can be obtained by using the %PADDR Built-In Function (e.g. %PADDR(myErrHandler)). You can name the local subprocedure for capturing errors anything you want, but it must specify these parameters in this order with the data types as specified in the sample error handler data structure.

D  pElemBegVal                  10a   value options(*nopass)

Override the default element begin value of '>' with the value of your choice. Recommend to leave at default unless you are experiencing codepage issues.

D  pElemContentVal...
D                               10a   value options(*nopass)

Override the default element content value of '/' with the value of your choice. Recommend to leave at default unless you are experiencing codepage issues.

D  pElemEndVal                  10a   value options(*nopass)

Override the default element begin value of '/>' with the value of your choice. Recommend to leave at default unless you are experiencing codepage issues.

D  pAttrVal                     10a   value options(*nopass)

Override the default attribute begin value of '@' with the value of your choice. Recommend to leave at default unless you are experiencing codepage issues.