1 | XOBVRMX ;mjk/alb - VistaLink Request Manager - Parse XML Requests using SAX interface ; 07/27/2002 13:00
|
---|
2 | ;;1.5;VistALink;;Sep 09, 2005
|
---|
3 | ;;Foundations Toolbox Release v1.5 [Build: 1.5.0.026]
|
---|
4 | ;
|
---|
5 | QUIT
|
---|
6 | ;
|
---|
7 | ; -- parse xml
|
---|
8 | EN(DOC,XOBOPT,XOBDATA,XOBHDLR) ; -- uses SAX parser
|
---|
9 | NEW XOBCBK,XOBICBK
|
---|
10 | DO SET(.XOBCBK)
|
---|
11 | DO EN^MXMLPRSE(DOC,.XOBCBK,.XOBOPT)
|
---|
12 | ENQ QUIT
|
---|
13 | ;
|
---|
14 | SET(XOBCBK) ; -- set the event interface entry points
|
---|
15 | SET XOBCBK("STARTELEMENT")="ELEST^XOBVRMX"
|
---|
16 | SET XOBCBK("ENDELEMENT")="ELEND^XOBVRMX"
|
---|
17 | SET XOBCBK("CHARACTERS")="CHR^XOBVRMX"
|
---|
18 | QUIT
|
---|
19 | ;
|
---|
20 | ELEST(ELE,ATR) ; -- element start callback
|
---|
21 | IF ELE="VistaLink" DO
|
---|
22 | . SET XOBDATA("VL VERSION")=$GET(ATR("version"),"1.0")
|
---|
23 | . ;
|
---|
24 | . ; -- set up request handler for message type
|
---|
25 | . SET XOBHDLR=+$$MSGTYPE^XOBVRH($GET(ATR("messageType"),"[unknown]"),.XOBHDLR)
|
---|
26 | ;
|
---|
27 | ; -- do start element callback for request handler
|
---|
28 | IF $GET(XOBHDLR(XOBHDLR)) XECUTE $GET(XOBHDLR(XOBHDLR,"CB","ELEST"))
|
---|
29 | QUIT
|
---|
30 | ;
|
---|
31 | ELEND(ELE) ; -- element end callback
|
---|
32 | ; -- do end element callback for request handler
|
---|
33 | IF $GET(XOBHDLR(XOBHDLR)) XECUTE $GET(XOBHDLR(XOBHDLR,"CB","ELEND"))
|
---|
34 | QUIT
|
---|
35 | ;
|
---|
36 | CHR(TXT) ; -- handler characters callback
|
---|
37 | ; -- do character callback for request handler
|
---|
38 | IF $GET(XOBHDLR(XOBHDLR)) XECUTE $GET(XOBHDLR(XOBHDLR,"CB","CHR"))
|
---|
39 | QUIT
|
---|
40 | ;
|
---|
41 | ESC(X) ; -- convert special characters to \x format ; not currently used -- note QUIT at start
|
---|
42 | QUIT X
|
---|
43 | ;
|
---|
44 | NEW C,Y,Z
|
---|
45 | FOR Z=1:1 SET C=$EXTRACT(X,Z) QUIT:C="" DO
|
---|
46 | .SET Y=$TRANSLATE(C,$CHAR(9,10,13,92),"tnc")
|
---|
47 | .SET:C'=Y $EXTRACT(X,Z)="" ;$S(Y="":"\\",1:"\"_Y),Z=Z+1
|
---|
48 | QUIT X
|
---|
49 | ;
|
---|