//--------------------------------------------------------------------------------------------------------------// // "If it's squinky, then you know it's BrilligWare!" // // // // Brillig Enterprises (aka Chris Pando) (C)2021 // // // // This work is licensed under a Creative Commons // // Attribution-NonCommercial-ShareAlike License: // // http://creativecommons.org/licenses/by-nc-sa/2.0/legalcode // //--------------------------------------------------------------------------------------------------------------// // // // // // If XML-SAX chokes on the document, return the error as a notify message // // // // // //--------------------------------------------------------------------------------------------------------------// Ctl-Opt dftActGrp(*No) actGrp(*Caller) debug(*Yes) option(*SrcStmt:*NoDebugIO) Main(wellformed) ; //--------------------------------------------------------------------------------------------------------------// // // //... procedure interfaces ... // // // //--------------------------------------------------------------------------------------------------------------// Dcl-PR rcvPgmMsg ExtPgm('QMHRCVPM') ; *n Char(256) ; *n Int(10) Const ; *n Char(8) Const ; *n Char(10) Const ; *n Int(10) Const ; *n Char(10) Const ; *n Char(4) Const ; *n Int(10) Const ; *n Char(10) Const ; *n Char(256) ; End-PR ; Dcl-PR sndPgmMsg ExtPgm('QMHSNDPM') ; *n Char(7) Const ; *n Char(20) Const ; *n Char(208) Const ; *n Int(10) Const ; *n Char(10) Const ; *n Char(10) Const ; *n Int(10) Const ; *n Char(4) ; *n Char(256) ; End-PR ; //--------------------------------------------------------------------------------------------------------------// // // // ... data structures ... // // // //--------------------------------------------------------------------------------------------------------------// // //... standard API error date structure (QUSEC) // Dcl-DS errDS ; *n Int(10) Inz(%Len(errDS)) ; errAvl Int(10) ; *n Char(7) ; *n Char(1) ; *n Char(240) ; End-DS ; Dcl-DS handlerInfo Len(1) End-DS ; //--------------------------------------------------------------------------------------------------------------// // // // Procedures // // // //--------------------------------------------------------------------------------------------------------------// // Mainline // //--------------------------------------------------------------------------------------------------------------// Dcl-Proc wellformed ; Dcl-PI *n ExtPgm ; xmlDocument Char(80) ; End-PI ; Monitor ; XML-SAX %Handler(handler:handlerInfo) %XML(%Trim(xmlDocument) : 'ccsid=37 ' + 'doc=file ') ; On-Error ; relayMsg() ; Return ; EndMon ; Return ; End-Proc ; //--------------------------------------------------------------------------------------------------------------// // Handler // //--------------------------------------------------------------------------------------------------------------// Dcl-Proc handler ; Dcl-PI *n Int(10) ; handlerInfoDS LikeDS(handlerInfo) ; event Int(10) Value ; dta@ Pointer Value ; dtaLen Int(20) Value ; exceptionID Int(10) Value ; End-PI ; Dcl-S dta Char(1024) Based(dta@) ; Select ; When ( event = *XML_START_DOCUMENT ) ; When ( event = *XML_START_ELEMENT ) ; When ( event = *XML_CHARS ) ; When ( event = *XML_END_ELEMENT ) ; EndSl ; Return 0 ; End-Proc ; //--------------------------------------------------------------------------------------------------------------// // relay message // //--------------------------------------------------------------------------------------------------------------// Dcl-Proc relayMsg ; Dcl-DS msgDta Len(256) Qualified ; *n Int(10) ;// bytes returned *n Int(10) ;// bytes available *n Int(10) ;// message severity msgID Char(7) ;// message identifier *n Char(2) ;// message type *n Char(4) ;// message key *n Char(7) ;// reserved *n Int(10) ;// CCSID conversion status *n Int(10) ;// CCSID of replacement data *n Int(10) ;// length of replacement data lenData Int(10) ;// length of replacement data available data Char(208) ;// replacement data End-DS ; Dcl-S msgKey Char(4) ; rcvPgmMsg( msgDta // message data : %Size(msgDta) // message data length : 'RCVM0100' // format name : '*' // call stack entry : 1 // call stack counter : '*ESCAPE ' // message type : ' ' // message key : 0 // wait time : '*REMOVE ' // message action : errDS // QUSEC ) ; sndPgmMsg( msgDta.msgID // always gonna be RNX0351 message identifier : 'QRNXMSG *LIBL ' // hard coded, so ugly qualified message file name : msgDta.data // message data : msgDta.lenData // message data length : '*NOTIFY ' // message type : '*EXT ' // call stack entry : 0 // call stack counter : msgKey // message key : errDS // QUSEC ) ; Return ; End-Proc ;