www.krengeltech.com

RXS_parse

From Wiki

User Guide

Contents

Description

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

Prototype

     D RXS_parse       pr            10i 0
     D  pFilePathOrData...
     D                                     value like(RXS_XmlData)  
     D  pType                              value like(RXS_Type)  
     D  pErrProcPtr                    *   procptr value
     D  pElemBegVal                  10a   value options(*nopass)
     D  pElemContentVal...
     D                               10a   value options(*nopass)
     D  pElemEndVal                  10a   value options(*nopass)
     D  pAttrVal                     10a   value options(*nopass)

Parameters

pFilePathOrData
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/aaron/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.’
pType
This parameter can either have RXS_STMF or RXS_VAR specified as it’s value. 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.
pErrProcPtr
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 (Get Procedure Address) RPG BIF (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 these data types:
     D errHandler      PI
     D  pCurLine                     10i 0 value
     D  pCurCol                      10i 0 value
     D  pErrStr                    1024a   value varying
pElemBegVal
Override the default element begin value of ‘>’ with the value of your choice. Recommend to leave at default unless you are experiencing codepage issues.
pElemContentVal
Override the default element content value of ‘/’ with the value of your choice. Recommend to leave at default unless you are experiencing codepage issues.
pElemEndVal
Override the default element begin value of ‘/>’ with the value of your choice. Recommend to leave at default unless you are experiencing codepage issues.
pAttrVal
Override the default attribute begin value of ‘@’ with the value of your choice. Recommend to leave at default unless you are experiencing codepage issues.

Return value

RXS_parse returns a 4-byte integer. This value will be returned as zero, unless the RXS_parseQuit procedure is invoked during parsing and a non-zero value was passed to RXS_parseQuit. In this case, the value returned from RXS_parse will be the value passed to RXS_parseQuit.

RXS_parse can either be called with or without the return value specified.

Notes / Examples

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)