source: FOIAVistA/trunk/r/XML_PARSER-MXML/MXMLTEST.m@ 1521

Last change on this file since 1521 was 628, checked in by George Lilly, 15 years ago

initial load of FOIAVistA 6/30/08 version

File size: 2.4 KB
Line 
1MXMLTEST ;SAIC/DKM - Test XML SAX interface ;01/31/2002 17:11
2 ;;7.3;TOOLKIT;**58**;Apr 25, 1995
3 ;=================================================================
4 ; This application acts as a client to the XML parser. It displays
5 ; parsing events as they occur and generates a summary at the end.
6EN(DOC,OPTION) ;
7 N CBK,CNT
8 W !!!,"Invoking XML Parser...",!!!
9 D SET(.CBK),EN^MXMLPRSE(DOC,.CBK,.OPTION)
10 S CNT=""
11 W !!!,"Parser Summary:",!!
12 F S CNT=$O(CNT(CNT)) Q:CNT="" W CNT,":",?25,CNT(CNT),!
13 Q
14 ; Direct entry of XML text from keyboard
15 ; Terminate text entry with a solitary '^'
16PASTE(OPTION) ;
17 N X,Y,GBL
18 S GBL=$NA(^TMP("MXMLTEST",$J))
19 K @GBL
20 F X=1:1 D Q:Y="^"
21 .W X,"> "
22 .R Y:$G(DTIME,600),!
23 .E S Y="^"
24 .S:Y'="^" @GBL@(X)=Y
25 D EN(GBL,.OPTION)
26 K @GBL
27 Q
28 ; Set the event interface entry points
29SET(CBK) N X,Y
30 K CBK
31 F X=0:1 S Y=$P($T(SETX+X),";;",2) Q:Y="" D
32 .S CBK(Y)=$E(Y,1,8)_"^MXMLTEST"
33 Q
34 ; Convert special characters to \x format
35ESC(X) N C,Y,Z
36 F Z=1:1 S C=$E(X,Z) Q:C="" D
37 .S Y=$TR(C,$C(9,10,13,92),"tnc")
38 .S:C'=Y $E(X,Z)=$S(Y="":"\\",1:"\"_Y),Z=Z+1
39 Q X
40SETX ;;STARTDOCUMENT
41 ;;ENDDOCUMENT
42 ;;DOCTYPE
43 ;;STARTELEMENT
44 ;;ENDELEMENT
45 ;;CHARACTERS
46 ;;PI
47 ;;ERROR
48 ;;COMMENT
49 ;;EXTERNAL
50 ;;NOTATION
51 ;;
52 ; Event interface callbacks
53STARTDOC ;
54ENDDOCUM W EVT,"()",!
55 Q
56DOCTYPE(P1,P2,P3) ;
57 W EVT,"(""",P1,""",""",P2,""",""",P3,""")",!
58 Q
59STARTELE(ELE,ATR) ;
60 D ARGS(ELE,.ATR),COUNT("Elements")
61 Q
62ARGS(ELE,ATR) ;
63 N X,Y
64 W EVT,"(""",ELE,""""
65 S X="",Y=","""
66 F S X=$O(ATR(X)) Q:X="" W Y,X,"=",$$ESC(ATR(X)) S Y=";"
67 W $S($L(Y)=1:""")",1:")"),!
68 Q
69ENDELEME(ELE) ;
70 W EVT,"(""",ELE,""")",!
71 Q
72CHARACTE(TXT) ;
73 D COUNT("Non-markup Content",$L(TXT))
74 W EVT,"(""",$$ESC(TXT),""")",!
75 Q
76PI(TGT,TXT) ;
77 D ARGS(TGT,.TXT)
78 D COUNT("Processing Instructions")
79 Q
80COMMENT(TXT) ;
81 W EVT,"(""",TXT,""")",!
82 D COUNT("Comments")
83 Q
84EXTERNAL(SYS,PUB,GBL) ;
85 W EVT,"(""",SYS,""",""",PUB,""")",!
86 D COUNT("External Entities")
87 Q
88NOTATION(NAME,SYS,PUB) ;
89 W EVT,"(""",NAME,""",""",SYS,""",""",PUB,""")",!
90 D COUNT("Notation Declarations")
91 Q
92COUNT(TYPE,INC) ;
93 S CNT(TYPE)=$G(CNT(TYPE))+$G(INC,1)
94 Q
95ERROR(ERR) ;
96 N X
97 S X=$P("Warning^Validation Error^Conformance Error","^",ERR("SEV")+1)
98 D COUNT(X_"s")
99 W X,": ",ERR("MSG")
100 W:$G(ERR("ARG"))'="" " (",ERR("ARG"),")"
101 W ". ","Line ",ERR("LIN"),", Position ",ERR("POS"),!
102 W $TR(ERR("XML"),$C(9,10,13)," "),!,$$REPEAT^XLFSTR("-",ERR("POS")-1),"^",!!
103 Q
Note: See TracBrowser for help on using the repository browser.