source: cprs/branches/tmg-cprs/m_files/TMGXML1.m@ 1117

Last change on this file since 1117 was 796, checked in by Kevin Toppenberg, 14 years ago

Initial upload

File size: 3.9 KB
Line 
1TMGXML1 ;TMG/kst/XML Exporter -- Testing code ;03/25/06
2 ;;1.0;TMG-LIB;**1**;07/09/05
3
4 ;"This is a test file for working with XML Documents
5Start ;
6
7 ;"Kevin Toppenberg, MD 7-9-04
8 ;"This is a test file for working with XML Documents
9
10 new Y,PATH,FILE,GBLREF
11 kill ^TMP("KT",$J)
12
13 set PATH="/home/kdtop"
14
15 write "-----------------------",!
16 read "Enter Filename:",FILE
17 write !
18 if FILE="^" quit
19 if FILE="" set FILE="XMLSample#2.xml" write "Using default: ",FILE,!
20
21 set GBLREF="^TMP(""KT"","_$J_",0)"
22 set Y=$$FTG^%ZISH(PATH,FILE,GBLREF,3)
23 if 'Y write "error opening file.",! quit
24
25 ;zwr ^TMP("KT",$JOB,*)
26
27 ;"do EN^MXMLTEST($NAME(^TMP("KT",$J)),"V")
28
29 write "---------------------------",!
30 write "Part #2",!,!
31
32 new FileName
33 set FileName=PATH_"/"_FILE
34 ;write "FileName=",FileName,!
35
36 new FnArray
37 set FnArray="Array of Callback Functions"
38 set FnArray("STARTDOCUMENT")="StartDoc^TMGXML1"
39 set FnArray("ENDDOCUMENT")="EndDoc^TMGXML1"
40 set FnArray("DOCTYPE")="DocType^TMGXML1"
41 set FnArray("STARTELEMENT")="StartElement^TMGXML1"
42 set FnArray("ENDELEMENT")="EndElement^TMGXML1"
43 set FnArray("CHARACTERS")="Chars^TMGXML1"
44
45 ;write "Here is FnArray",!
46 ;zwr FnArray(*)
47
48 write "Calling EN^MXMLPRSE",!
49 do EN^MXMLPRSE($NAME(^TMP("KT",$J)),.FnArray)
50 ;do EN^MXMLPRSE(FileName,.FnArray)
51 write "Done calling EN^MXMLPRSE",!
52
53 write "---------------------------",!
54 write "Part #3",!,!
55
56 new ParseHandle
57 write "Calling EN^MXMLDOM",!
58 set ParseHandle=$$EN^MXMLDOM($NAME(^TMP("KT",$J)),"V")
59 write "Done calling EN^MXMLDOM",!
60 write "Handle=",ParseHandle,!
61
62 do ShowNode(1,0)
63 do ListChildren(1,1)
64
65
66 do DELETE^MXMLDOM(ParseHandle)
67
68 kill ^TMP("KT",$J)
69 write "********************",!
70 write "Quiting normally",!
71
72QuitLabel quit
73
74
75 ;"-------------------------------------------------------------
76
77StartDoc
78 write "##Starting Document Processing##",!
79 quit
80
81EndDoc
82 write "##End of Document Processing##",!
83 quit
84
85
86DocType(ROOT,PUBID,SYSID)
87 write "Doctype encountered.",!
88 write "ROOT=",ROOT,!
89 write "PUBID=",PUBID,!
90 write "SYSID=",SYSID,!
91 quit
92
93
94StartElement(NAME,ATTRLIST)
95 write "Attrib:"
96 write "Name=",NAME,!
97 if $data(ATTRLIST) do
98 . write "AttrList:"
99 . zwr ATTRLIST
100 quit
101
102EndElement(NAME)
103 write "End Attrib:"
104 write NAME,!
105 quit
106
107Chars(TEXT)
108 write "TEXT:",TEXT,!
109 quit
110
111
112 ;"-------------------------------------------------------------
113
114ListChildren(Node,IndentN)
115 new ChildNode
116 set ChildNode=$$CHILD^MXMLDOM(ParseHandle,Node,0)
117 if ChildNode=0 quit
118
119 new loop
120 for loop=1:1 do if ChildNode=0 quit
121 . do ShowNode(ChildNode,IndentN)
122 . do ListChildren(ChildNode,IndentN+1)
123 . set ChildNode=$$CHILD^MXMLDOM(ParseHandle,Node,ChildNode)
124
125 quit
126
127ShowNode(Node,IndentN)
128 new NodeText
129 new AttribText
130
131 do Indent(IndentN)
132 write $$NAME^MXMLDOM(ParseHandle,Node),!
133 if $$CMNT^MXMLDOM(ParseHandle,Node,$NAME(NodeText)) do
134 . do Indent(IndentN)
135 . write " Comment: ",NodeText(1),!
136 if $$TEXT^MXMLDOM(ParseHandle,Node,$NAME(NodeText)) do
137 . do Indent(IndentN)
138 . write " '",NodeText(1),"'",!
139 set AttribText=$$ATTRIB^MXMLDOM(ParseHandle,Node)
140 if $data(AttribText),AttribText'="" do
141 . do Indent(IndentN)
142 . write " Attrib: ",AttribText,"="
143 . write $$VALUE^MXMLDOM(ParseHandle,Node,AttribText),!
144
145 quit
146
147
148Indent(IndentN)
149 for i=1:1:IndentN write " "
150
Note: See TracBrowser for help on using the repository browser.