XOBVRMX ;mjk/alb - VistaLink Request Manager - Parse XML Requests using SAX interface ; 07/27/2002 13:00
;;1.5;VistALink;;Sep 09, 2005
;;Foundations Toolbox Release v1.5 [Build: 1.5.0.026]
;
QUIT
;
; -- parse xml
EN(DOC,XOBOPT,XOBDATA,XOBHDLR) ; -- uses SAX parser
NEW XOBCBK,XOBICBK
DO SET(.XOBCBK)
DO EN^MXMLPRSE(DOC,.XOBCBK,.XOBOPT)
ENQ QUIT
;
SET(XOBCBK) ; -- set the event interface entry points
SET XOBCBK("STARTELEMENT")="ELEST^XOBVRMX"
SET XOBCBK("ENDELEMENT")="ELEND^XOBVRMX"
SET XOBCBK("CHARACTERS")="CHR^XOBVRMX"
QUIT
;
ELEST(ELE,ATR) ; -- element start callback
IF ELE="VistaLink" DO
. SET XOBDATA("VL VERSION")=$GET(ATR("version"),"1.0")
. ;
. ; -- set up request handler for message type
. SET XOBHDLR=+$$MSGTYPE^XOBVRH($GET(ATR("messageType"),"[unknown]"),.XOBHDLR)
;
; -- do start element callback for request handler
IF $GET(XOBHDLR(XOBHDLR)) XECUTE $GET(XOBHDLR(XOBHDLR,"CB","ELEST"))
QUIT
;
ELEND(ELE) ; -- element end callback
; -- do end element callback for request handler
IF $GET(XOBHDLR(XOBHDLR)) XECUTE $GET(XOBHDLR(XOBHDLR,"CB","ELEND"))
QUIT
;
CHR(TXT) ; -- handler characters callback
; -- do character callback for request handler
IF $GET(XOBHDLR(XOBHDLR)) XECUTE $GET(XOBHDLR(XOBHDLR,"CB","CHR"))
QUIT
;
ESC(X) ; -- convert special characters to \x format ; not currently used -- note QUIT at start
QUIT X
;
NEW C,Y,Z
FOR Z=1:1 SET C=$EXTRACT(X,Z) QUIT:C="" DO
.SET Y=$TRANSLATE(C,$CHAR(9,10,13,92),"tnc")
.SET:C'=Y $EXTRACT(X,Z)="" ;$S(Y="":"\\",1:"\"_Y),Z=Z+1
QUIT X
;
XOBVRMX ;mjk/alb - VistaLink Request Manager - Parse XML Requests using SAX interface ; 07/27/2002 13:00
+1 ;;1.5;VistALink;;Sep 09, 2005
+2 ;;Foundations Toolbox Release v1.5 [Build: 1.5.0.026]
+3 ;
+4 QUIT
+5 ;
+6 ; -- parse xml
EN(DOC,XOBOPT,XOBDATA,XOBHDLR) ; -- uses SAX parser
+1 NEW XOBCBK,XOBICBK
+2 DO SET(.XOBCBK)
+3 DO EN^MXMLPRSE(DOC,.XOBCBK,.XOBOPT)
ENQ QUIT
+1 ;
SET(XOBCBK) ; -- set the event interface entry points
+1 SET XOBCBK("STARTELEMENT")="ELEST^XOBVRMX"
+2 SET XOBCBK("ENDELEMENT")="ELEND^XOBVRMX"
+3 SET XOBCBK("CHARACTERS")="CHR^XOBVRMX"
+4 QUIT
+5 ;
ELEST(ELE,ATR) ; -- element start callback
+1 IF ELE="VistaLink"
Begin DoDot:1
+2 SET XOBDATA("VL VERSION")=$GET(ATR("version"),"1.0")
+3 ;
+4 ; -- set up request handler for message type
+5 SET XOBHDLR=+$$MSGTYPE^XOBVRH($GET(ATR("messageType"),"[unknown]"),.XOBHDLR)
End DoDot:1
+6 ;
+7 ; -- do start element callback for request handler
+8 IF $GET(XOBHDLR(XOBHDLR))
XECUTE $GET(XOBHDLR(XOBHDLR,"CB","ELEST"))
+9 QUIT
+10 ;
ELEND(ELE) ; -- element end callback
+1 ; -- do end element callback for request handler
+2 IF $GET(XOBHDLR(XOBHDLR))
XECUTE $GET(XOBHDLR(XOBHDLR,"CB","ELEND"))
+3 QUIT
+4 ;
CHR(TXT) ; -- handler characters callback
+1 ; -- do character callback for request handler
+2 IF $GET(XOBHDLR(XOBHDLR))
XECUTE $GET(XOBHDLR(XOBHDLR,"CB","CHR"))
+3 QUIT
+4 ;
ESC(X) ; -- convert special characters to \x format ; not currently used -- note QUIT at start
+1 QUIT X
+2 ;
+3 NEW C,Y,Z
+4 FOR Z=1:1
SET C=$EXTRACT(X,Z)
IF C=""
QUIT
Begin DoDot:1
+5 SET Y=$TRANSLATE(C,$CHAR(9,10,13,92),"tnc")
+6 ;$S(Y="":"\\",1:"\"_Y),Z=Z+1
IF C'=Y
SET $EXTRACT(X,Z)=""
End DoDot:1
+7 QUIT X
+8 ;