source: ccr/trunk/p/GPLXPATH.m@ 6

Last change on this file since 6 was 3, checked in by George Lilly, 16 years ago

Inital release of GPL*.m files for creating a CCR from VistA. Usage EXPORTGPLCCR

File size: 19.3 KB
Line 
1GPLXPATH ; CCDCCR/GPL - XPATH XML manipulation utilities; 6/1/08
2 ;;0.2;CCDCCR;nopatch;noreleasedate
3 W "This is an XML XPATH utility library",!
4 W !
5 Q
6 ;
7OUTPUT(OUTARY,OUTNAME,OUTDIR) ; WRITE AN ARRAY TO A FILE
8 ;
9 N Y
10 S Y=$$GTF^%ZISH(OUTARY,$QL(OUTARY),OUTDIR,OUTNAME)
11 I Y W "WROTE FILE: ",OUTNAME," TO ",OUTDIR,!
12 ; $NA(^TMP(14216,"FILE",0)),3,"/home/wvehr3","test.xml")
13 Q
14 ;
15PUSH(STK,VAL) ; pushs VAL onto STK and updates STK(0)
16 ; VAL IS A STRING AND STK IS PASSED BY NAME
17 ;
18 I '$D(@STK@(0)) S @STK@(0)=0 ; IF THE ARRAY IS EMPTY, INITIALIZE
19 S @STK@(0)=@STK@(0)+1 ; INCREMENT ARRAY DEPTH
20 S @STK@(@STK@(0))=VAL ; PUT VAL A THE END OF THE ARRAY
21 Q
22 ;
23POP(STK,VAL) ; POPS THE LAST VALUE OFF THE STK AND RETURNS IT IN VAL
24 ; VAL AND STK ARE PASSED BY REFERENCE
25 ;
26 I @STK@(0)<1 S VAL="",@STK@(0)=0 Q ; IF ARRAY IS EMPTY
27 I @STK@(0)>0 D
28 . S VAL=@STK@(@STK@(0))
29 . K @STK@(@STK@(0))
30 . S @STK@(0)=@STK@(0)-1 ; NEW DEPTH OF THE ARRAY
31 Q
32 ;
33MKMDX(STK,RTN) ; MAKES A MUMPS INDEX FROM THE ARRAY STK
34 ; RTN IS SET TO //FIRST/SECOND/THIRD" FOR THREE ARRAY ELEMENTS
35 S RTN=""
36 N I
37 ; W "STK= ",STK,!
38 I @STK@(0)>0 D ; IF THE ARRAY IS NOT EMPTY
39 . S RTN="//"_@STK@(1) ; FIRST ELEMENT NEEDS NO SEMICOLON
40 . I @STK@(0)>1 D ; SUBSEQUENT ELEMENTS NEED A SEMICOLON
41 . . F I=2:1:@STK@(0) S RTN=RTN_"/"_@STK@(I)
42 Q
43 ;
44XNAME(ISTR) ; FUNCTION TO EXTRACT A NAME FROM AN XML FRAG
45 ; </NAME> AND <NAME ID=XNAME> WILL RETURN NAME
46 ; ISTR IS PASSED BY VALUE
47 N CUR,TMP
48 I ISTR?.E1"<".E D ; STRIP OFF LEFT BRACKET
49 . S TMP=$P(ISTR,"<",2)
50 I TMP?1"/".E D ; ALSO STRIP OFF SLASH IF PRESENT IE </NAME>
51 . S TMP=$P(TMP,"/",2)
52 S CUR=$P(TMP,">",1) ; EXTRACT THE NAME
53 ; W "CUR= ",CUR,!
54 I CUR?.1"_"1.A1" ".E D ; CONTAINS A BLANK IE NAME ID=TEST>
55 . S CUR=$P(CUR," ",1) ; STRIP OUT BLANK AND AFTER
56 ; W "CUR2= ",CUR,!
57 Q CUR
58 ;
59INDEX(ZXML) ; parse the XML in ZXML and produce an XPATH index
60 ; ex. ZXML(FIRST,SECOND,THIRD,FOURTH)=FIRSTLINE^LASTLINE
61 ; WHERE FIRSTLINE AND LASTLINE ARE THE BEGINNING AND ENDING OF THE
62 ; XML SECTION
63 ; ZXML IS PASSED BY NAME
64 N I,LINE,FIRST,LAST,CUR,TMP,MDX,FOUND
65 N GPLSTK ; LEAVE OUT FOR DEBUGGING
66 I '$D(@ZXML@(0)) D ; NO XML PASSED
67 . W "ERROR IN XML FILE",!
68 S GPLSTK(0)=0 ; INITIALIZE STACK
69 F I=1:1:@ZXML@(0) D ; PROCESS THE ENTIRE ARRAY
70 . S LINE=@ZXML@(I)
71 . ;W LINE,!
72 . S FOUND=0 ; INTIALIZED FOUND FLAG
73 . I LINE?.E1"<!".E S FOUND=1 ; SKIP OVER COMMENTS
74 . I FOUND'=1 D
75 . . I (LINE?.E1"<"1.E1"</".E)!(LINE?.E1"<"1.E1"/>".E) D
76 . . . ; THIS IS THE CASE THERE SECTION BEGINS AND ENDS ON THE SAME LINE
77 . . . ; W "FOUND ",LINE,!
78 . . . S FOUND=1 ; SET FOUND FLAG
79 . . . S CUR=$$XNAME(LINE) ; EXTRACT THE NAME
80 . . . D PUSH("GPLSTK",CUR) ; ADD TO THE STACK
81 . . . D MKMDX("GPLSTK",.MDX) ; GENERATE THE M INDEX
82 . . . ; W "MDX=",MDX,!
83 . . . I $D(@ZXML@(MDX)) D ; IN THE INDEX, IS A MULTIPLE
84 . . . . S $P(@ZXML@(MDX),"^",2)=I ; UPDATE LAST LINE NUMBER
85 . . . I '$D(@ZXML@(MDX)) D ; NOT IN THE INDEX, IS NOT A MULTIPLE
86 . . . . S @ZXML@(MDX)=I_"^"_I ; ADD INDEX ENTRY-FIRST AND LAST LINE
87 . . . D POP("GPLSTK",.TMP) ; REMOVE FROM STACK
88 . I FOUND'=1 D ; THE LINE DOESN'T CONTAIN THE START AND END OF A SEC
89 . . I LINE?.E1"</"1.E D ; LINE CONTAINS END OF A SECTION
90 . . . ; W "FOUND ",LINE,!
91 . . . S FOUND=1 ; SET FOUND FLAG
92 . . . S CUR=$$XNAME(LINE) ; EXTRACT THE NAME
93 . . . D MKMDX("GPLSTK",.MDX) ; GENERATE THE M INDEX
94 . . . S $P(@ZXML@(MDX),"^",2)=I ; UPDATE LAST LINE NUMBER
95 . . . D POP("GPLSTK",.TMP) ; REMOVE FROM STACK
96 . . . I TMP'=CUR D ; MALFORMED XML, END MUST MATCH START
97 . . . . W "MALFORMED XML ",CUR,"LINE "_I_LINE,!
98 . . . . Q
99 . I FOUND'=1 D ; THE LINE MIGHT CONTAIN THE BEGINNING OF A SECTION
100 . . I (LINE?.E1"<"1.E)&(LINE'["?>") D ; BEGINNING OF A SECTION
101 . . . ; W "FOUND ",LINE,!
102 . . . S FOUND=1 ; SET FOUND FLAG
103 . . . S CUR=$$XNAME(LINE) ; EXTRACT THE NAME
104 . . . D PUSH("GPLSTK",CUR) ; ADD TO THE STACK
105 . . . D MKMDX("GPLSTK",.MDX) ; GENERATE THE M INDEX
106 . . . ; W "MDX=",MDX,!
107 . . . I $D(@ZXML@(MDX)) D ; IN THE INDEX, IS A MULTIPLE
108 . . . . S $P(@ZXML@(MDX),"^",2)=I ; UPDATE LAST LINE NUMBER
109 . . . I '$D(@ZXML@(MDX)) D ; NOT IN THE INDEX, IS NOT A MULTIPLE
110 . . . . S @ZXML@(MDX)=I_"^" ; INSERT INTO THE INDEX
111 S @ZXML@("INDEXED")=""
112 S @ZXML@("//")="1^"_@ZXML@(0) ; ROOT XPATH
113 Q
114 ;
115QUERY(IARY,XPATH,OARY) ; RETURNS THE XML ARRAY MATCHING THE XPATH EXPRESSION
116 ; XPATH IS OF THE FORM "//FIRST/SECOND/THIRD"
117 ; IARY AND OARY ARE PASSED BY NAME
118 I '$D(@IARY@("INDEXED")) D ; INDEX IS NOT PRESENT IN IARY
119 . D INDEX(IARY) ; GENERATE AN INDEX FOR THE XML
120 N FIRST,LAST ; FIRST AND LAST LINES OF ARRAY TO RETURN
121 N TMP,I,J,QXPATH
122 S FIRST=1
123 S LAST=@IARY@(0) ; FIRST AND LAST DEFAULT TO ROOT
124 I XPATH'="//" D ; NOT A ROOT QUERY
125 . S TMP=@IARY@(XPATH) ; LOOK UP LINE VALUES
126 . S FIRST=$P(TMP,"^",1)
127 . S LAST=$P(TMP,"^",2)
128 K @OARY
129 S @OARY@(0)=+LAST-FIRST+1
130 S J=1
131 FOR I=FIRST:1:LAST D
132 . S @OARY@(J)=@IARY@(I) ; COPY THE LINE TO OARY
133 . S J=J+1
134 ; ZWR OARY
135 Q
136 ;
137XF(IDX,XPATH) ; EXTRINSIC TO RETURN THE STARTING LINE FROM AN XPATH
138 ; INDEX WITH TWO PIECES START^FINISH
139 ; IDX IS PASSED BY NAME
140 Q $P(@IDX@(XPATH),"^",1)
141 ;
142XL(IDX,XPATH) ; EXTRINSIC TO RETURN THE LAST LINE FROM AN XPATH
143 ; INDEX WITH TWO PIECES START^FINISH
144 ; IDX IS PASSED BY NAME
145 Q $P(@IDX@(XPATH),"^",2)
146 ;
147START(ISTR) ; EXTRINSIC TO RETURN THE STARTING LINE FROM AN INDEX
148 ; TYPE STRING WITH THREE PIECES ARRAY;START;FINISH
149 ; COMPANION TO FINISH ; IDX IS PASSED BY NAME
150 Q $P(ISTR,";",2)
151 ;
152FINISH(ISTR) ; EXTRINSIC TO RETURN THE LAST LINE FROM AN INDEX
153 ; TYPE STRING WITH THREE PIECES ARRAY;START;FINISH
154 Q $P(ISTR,";",3)
155 ;
156ARRAY(ISTR) ; EXTRINSIC TO RETURN THE ARRAY REFERENCE FROM AN INDEX
157 ; TYPE STRING WITH THREE PIECES ARRAY;START;FINISH
158 Q $P(ISTR,";",1)
159 ;
160BUILD(BLIST,BDEST) ; A COPY MACHINE THAT TAKE INSTRUCTIONS IN ARRAY BLIST
161 ; WHICH HAVE ARRAY;START;FINISH AND COPIES THEM TO DEST
162 ; DEST IS CLEARED TO START
163 ; USES PUSH TO DO THE COPY
164 N I
165 K @BDEST
166 F I=1:1:@BLIST@(0) D ; FOR EACH INSTRUCTION IN BLIST
167 . N J,ATMP
168 . S ATMP=$$ARRAY(@BLIST@(I))
169 . I DEBUG W "ATMP=",ATMP,!
170 . I DEBUG W @BLIST@(I),!
171 . F J=$$START(@BLIST@(I)):1:$$FINISH(@BLIST@(I)) D ;
172 . . ; FOR EACH LINE IN THIS INSTR
173 . . I DEBUG W "BDEST= ",BDEST,!
174 . . I DEBUG W "ATMP= ",@ATMP@(J),!
175 . . D PUSH(BDEST,@ATMP@(J))
176 Q
177 ;
178QUEUE(BLST,ARRAY,FIRST,LAST) ; ADD AN ENTRY TO A BLIST
179 ;
180 I DEBUG W "QUEUEING ",BLST,!
181 D PUSH(BLST,ARRAY_";"_FIRST_";"_LAST)
182 Q
183 ;
184CP(CPSRC,CPDEST) ; COPIES CPSRC TO CPDEST BOTH PASSED BY NAME
185 ; KILLS CPDEST FIRST
186 N CPINSTR
187 I DEBUG W "MADE IT TO COPY",CPSRC,CPDEST,!
188 I @CPSRC@(0)<1 D ; BAD LENGTH
189 . W "ERROR IN COPY BAD SOURCE LENGTH: ",CPSRC,!
190 . Q
191 D QUEUE("CPINSTR",CPSRC,1,@CPSRC@(0)) ; BLIST FOR ENTIRE ARRAY
192 D BUILD("CPINSTR",CPDEST)
193 Q
194 ;
195QOPEN(QOBLIST,QOXML,QOXPATH) ; ADD ALL BUT THE LAST LINE OF QOXML TO QOBLIST
196 ; WARNING NEED TO DO QCLOSE FOR SAME XML BEFORE CALLING BUILD
197 ; QOXPATH IS OPTIONAL - IF PROVIDED, WILL OPEN INSIDE THE XPATH POINT
198 ; USED TO INSERT CHILDREN NODES
199 I @QOXML@(0)<1 D ; MALFORMED XML
200 . W "MALFORMED XML PASSED TO QOPEN: ",QOXML,!
201 . Q
202 I DEBUG W "DOING QOPEN",!
203 N S1,E1,QOT,QOTMP
204 S S1=1 ; OPEN FROM THE BEGINNING OF THE XML
205 I $D(QOXPATH) D ; XPATH PROVIDED
206 . D QUERY(QOXML,QOXPATH,"QOT") ; INSURE INDEX
207 . S E1=$P(@QOXML@(QOXPATH),"^",2)-1
208 I '$D(QOXPATH) D ; NO XPATH PROVIDED, OPEN AT ROOT
209 . S E1=@QOXML@(0)-1
210 D QUEUE(QOBLIST,QOXML,S1,E1)
211 ; S QOTMP=QOXML_"^"_S1_"^"_E1
212 ; D PUSH(QOBLIST,QOTMP)
213 Q
214 ;
215QCLOSE(QCBLIST,QCXML,QCXPATH) ; CLOSE XML AFTER A QOPEN
216 ; ADDS THE LIST LINE OF QCXML TO QCBLIST
217 ; USED TO FINISH INSERTING CHILDERN NODES
218 ; QCXPATH IS OPTIONAL - IF PROVIDED, WILL CLOSE UNTIL THE END
219 ; IF QOPEN WAS CALLED WITH XPATH, QCLOSE SHOULD BE TOO
220 I @QCXML@(0)<1 D ; MALFORMED XML
221 . W "MALFORMED XML PASSED TO QCLOSE: ",QCXML,!
222 I DEBUG W "GOING TO CLOSE",!
223 N S1,E1,QCT,QCTMP
224 S E1=@QCXML@(0) ; CLOSE UNTIL THE END OF THE XML
225 I $D(QCXPATH) D ; XPATH PROVIDED
226 . D QUERY(QCXML,QCXPATH,"QCT") ; INSURE INDEX
227 . S S1=$P(@QCXML@(QCXPATH),"^",2) ; REMAINING XML
228 I '$D(QCXPATH) D ; NO XPATH PROVIDED, CLOSE AT ROOT
229 . S S1=@QCXML@(0)
230 D QUEUE(QCBLIST,QCXML,S1,E1)
231 ; D PUSH(QCBLIST,QCXML_";"_S1_";"_E1)
232 Q
233 ;
234INSERT(INSXML,INSNEW,INSXPATH) ; INSERT INSNEW INTO INSXML AT THE
235 ; INSXPATH XPATH POINT INSXPATH IS OPTIONAL - IF IT IS
236 ; OMITTED, INSERTION WILL BE AT THE ROOT
237 ; NOTE INSERT IS NON DESTRUCTIVE AND WILL ADD THE NEW
238 ; XML AT THE END OF THE XPATH POINT
239 ; INSXML AND INSNEW ARE PASSED BY NAME INSXPATH IS A VALUE
240 ; N INSBLD,INSTMP
241 I DEBUG W "DOING INSERT ",INSXML,INSNEW,INSXPATH,!
242 I DEBUG F G1=1:1:@INSXML@(0) W @INSXML@(G1),!
243 I '$D(@INSXML@(0)) D ; INSERT INTO AN EMPTY ARRAY
244 . W "DOING A BAD COPY",!
245 . D CP^GPLXPATH(INSNEW,INXML) ; JUST COPY INTO THE OUTPUT
246 I $D(@INSXML@(0)) D ; IF ORIGINAL ARRAY IS NOT EMPTY
247 . W "GOT HERE",!
248 . I $D(INSXPATH) D ; XPATH PROVIDED
249 . . D QOPEN("INSBLD",INSXML,INSXPATH) ; COPY THE BEFORE
250 . . I DEBUG ZWR INSBLD
251 . I '$D(INSXPATH) D ; NO XPATH PROVIDED, OPEN AT ROOT
252 . . D QOPEN("INSBLD",INSXML,"//") ; OPEN WITH ROOT XPATH
253 . D QUEUE("INSBLD",INSNEW,1,@INSNEW@(0)) ; COPY IN NEW XML
254 . I $D(INSXPATH) D ; XPATH PROVIDED
255 . . D QCLOSE("INSBLD",INSXML,INSXPATH) ; CLOSE WITH XPATH
256 . I '$D(INSXPATH) D ; NO XPATH PROVIDED, CLOSE AT ROOT
257 . . D QCLOSE("INSBLD",INSXML,"//") ; CLOSE WITH ROOT XPATH
258 . D BUILD("INSBLD",INSTMP) ; PUT RESULTS IN INDEST
259 . D CP^GPLXPATH(INSTMP,INSXML) ; COPY BUFFER TO SOURCE
260 Q
261 ;
262INSINNER(INNXML,INNNEW,INNXPATH) ; INSERT THE INNER XML OF INNNEW
263 ; INTO INNXML AT THE INNXPATH XPATH POINT
264 ;
265 N INNBLD,UXPATH
266 N INNTBUF
267 S INNTBUF=$NA(^TMP($J,"INNTBUF"))
268 I '$D(INNXPATH) D ; XPATH NOT PASSED
269 . S UXPATH="//" ; USE ROOT XPATH
270 I $D(INNXPATH) S UXPATH=INNXPATH ; USE THE XPATH THAT'S PASSED
271 I '$D(@INNXML@(0)) D ; INNXML IS EMPTY
272 . D QUEUE^GPLXPATH("INNBLD",INNNEW,2,@INNNEW@(0)-1) ; JUST INNER XML
273 . D BUILD("INNBLD",INNXML)
274 I @INNXML@(0)>0 D ; NOT EMPTY
275 . D QOPEN("INNBLD",INNXML,UXPATH) ;
276 . D QUEUE("INNBLD",INNNEW,2,@INNNEW@(0)-1) ; JUST INNER XML
277 . D QCLOSE("INNBLD",INNXML,UXPATH)
278 . D BUILD("INNBLD",INNTBUF) ; BUILD TO BUFFER
279 . D CP(INNTBUF,INNXML) ; COPY BUFFER TO DEST
280 Q
281 ;
282REPLACE(REXML,RENEW,REXPATH) ; REPLACE THE XML AT THE XPATH POINT
283 ; WITH RENEW - NOTE THIS WILL DELETE WHAT WAS THERE BEFORE
284 ; REXML AND RENEW ARE PASSED BY NAME XPATH IS A VALUE
285 ; THE DELETED XML IS PUT IN ^TMP($J,"REPLACE_OLD")
286 N REBLD,XFIRST,XLAST,OLD,XNODE,RETMP
287 S OLD=$NA(^TMP($J,"REPLACE_OLD"))
288 D QUERY(REXML,REXPATH,OLD) ; CREATE INDEX, TEST XPATH, MAKE OLD
289 S XNODE=@REXML@(REXPATH) ; PULL OUT FIRST AND LAST LINE PTRS
290 S XFIRST=$P(XNODE,"^",1)
291 S XLAST=$P(XNODE,"^",2)
292 D QUEUE("REBLD",REXML,1,XFIRST) ; THE BEFORE
293 I RENEW'="" D ; NEW XML IS NOT NULL
294 . D QUEUE("REBLD",RENEW,1,@RENEW@(0)) ; THE NEW
295 D QUEUE("REBLD",REXML,XLAST,@REXML@(0)) ; THE REST
296 I DEBUG W "REPALCE PREBUILD",!
297 I DEBUG ZWR REBLD
298 D BUILD("REBLD","RTMP")
299 K @REXML ; KILL WHAT WAS THERE
300 D CP("RTMP",REXML) ; COPY IN THE RESULT
301 Q
302 ;
303MISSING(IXML,OARY) ; SEARTH THROUGH INXLM AND PUT ANY @@X@@ VARS IN OARY
304 ; W "Reporting on the missing",!
305 ; W OARY
306 I '$D(@IXML@(0)) W "MALFORMED XML PASSED TO MISSING",! Q
307 N I
308 S @OARY@(0)=0 ; INITIALIZED MISSING COUNT
309 F I=1:1:@IXML@(0) D ; LOOP THROUGH WHOLE ARRAY
310 . I @IXML@(I)?.E1"@@".E D ; MISSING VARIABLE HERE
311 . . D PUSH^GPLXPATH(OARY,$P(@IXML@(I),"@@",2)) ; ADD TO OUTARY
312 . . Q
313 Q
314 ;
315MAP(IXML,INARY,OXML) ; SUBSTITUTE @@X@@ VARS IN IXML WITH VALUES IN INARY
316 ; AND PUT THE RESULTS IN OXML
317 I '$D(@IXML@(0)) W "MALFORMED XML PASSED TO MAP",! Q
318 I $O(@INARY@(""))="" W "EMPTY ARRAY PASSED TO MAP",! Q
319 N I,TNAM,TVAL
320 S @OXML@(0)=@IXML@(0) ; TOTAL LINES IN OUTPUT
321 F I=1:1:@OXML@(0) D ; LOOP THROUGH WHOLE ARRAY
322 . S @OXML@(I)=@IXML@(I) ; COPY THE LINE TO OUTPUT
323 . I @OXML@(I)?.E1"@@".E D ; IS THERE A VARIABLE HERE?
324 . . S TNAM=$P(@OXML@(I),"@@",2) ; EXTRACT THE VARIABLE NAME
325 . . I $D(@INARY@(TNAM)) D ; IS THE VARIABLE IN THE MAP?
326 . . . S TVAL=@INARY@(TNAM) ; PULL OUT MAPPED VALUE
327 . . . S @OXML@(I)=$P(@OXML@(I),"@@",1)_TVAL_$P(@OXML@(I),"@@",3) ;MAPIT
328 W "MAPPED",!
329 Q
330 ;
331PARY(GLO) ;PRINT AN ARRAY
332 N I
333 F I=1:1:@GLO@(0) W @GLO@(I),!
334 Q
335 ;
336TEST ; RUN ALL THE TEST CASES
337 N ZTMP
338 D ZLOAD^GPLUNIT("ZTMP","GPLXPATH")
339 D ZTEST^GPLUNIT(.ZTMP,"ALL")
340 W "PASSED: ",TPASSED,!
341 W "FAILED: ",TFAILED,!
342 W !
343 ; W "THE TESTS!",!
344 ; ZWR ZTMP
345 Q
346 ;
347ZTEST(WHICH) ; RUN ONE SET OF TESTS
348 N ZTMP
349 D ZLOAD^GPLUNIT("ZTMP","GPLXPATH")
350 D ZTEST^GPLUNIT(.ZTMP,WHICH)
351 Q
352 ;
353TLIST ; LIST THE TESTS
354 N ZTMP
355 D ZLOAD^GPLUNIT("ZTMP","GPLXPATH")
356 D TLIST^GPLUNIT(.ZTMP)
357 Q
358 ;
359;;><TEST>
360;;><INIT>
361;;>>>K GPL S GPL=""
362;;>>>D PUSH^GPLXPATH("GPL","FIRST")
363;;>>>D PUSH^GPLXPATH("GPL","SECOND")
364;;>>>D PUSH^GPLXPATH("GPL","THIRD")
365;;>>>D PUSH^GPLXPATH("GPL","FOURTH")
366;;>>?GPL(0)=4
367;;><INITXML>
368;;>>>K GXML S GXML=""
369;;>>>D PUSH^GPLXPATH("GXML","<FIRST>")
370;;>>>D PUSH^GPLXPATH("GXML","<SECOND>")
371;;>>>D PUSH^GPLXPATH("GXML","<THIRD>")
372;;>>>D PUSH^GPLXPATH("GXML","<FOURTH>@@DATA1@@</FOURTH>")
373;;>>>D PUSH^GPLXPATH("GXML","<FIFTH>")
374;;>>>D PUSH^GPLXPATH("GXML","@@DATA2@@")
375;;>>>D PUSH^GPLXPATH("GXML","</FIFTH>")
376;;>>>D PUSH^GPLXPATH("GXML","<SIXTH ID=""SELF"" />")
377;;>>>D PUSH^GPLXPATH("GXML","</THIRD>")
378;;>>>D PUSH^GPLXPATH("GXML","<SECOND>")
379;;>>>D PUSH^GPLXPATH("GXML","</SECOND>")
380;;>>>D PUSH^GPLXPATH("GXML","</SECOND>")
381;;>>>D PUSH^GPLXPATH("GXML","</FIRST>")
382;;><INITXML2>
383;;>>>K GXML S GXML=""
384;;>>>D PUSH^GPLXPATH("GXML","<FIRST>")
385;;>>>D PUSH^GPLXPATH("GXML","<SECOND>")
386;;>>>D PUSH^GPLXPATH("GXML","<THIRD>")
387;;>>>D PUSH^GPLXPATH("GXML","<FOURTH>DATA1</FOURTH>")
388;;>>>D PUSH^GPLXPATH("GXML","<FOURTH>")
389;;>>>D PUSH^GPLXPATH("GXML","DATA2")
390;;>>>D PUSH^GPLXPATH("GXML","</FOURTH>")
391;;>>>D PUSH^GPLXPATH("GXML","</THIRD>")
392;;>>>D PUSH^GPLXPATH("GXML","<_SECOND>")
393;;>>>D PUSH^GPLXPATH("GXML","<FOURTH>DATA3</FOURTH>")
394;;>>>D PUSH^GPLXPATH("GXML","</_SECOND>")
395;;>>>D PUSH^GPLXPATH("GXML","</SECOND>")
396;;>>>D PUSH^GPLXPATH("GXML","</FIRST>")
397;;><PUSHPOP>
398;;>>>D ZLOAD^GPLUNIT("ZTMP","GPLXPATH")
399;;>>>D ZTEST^GPLUNIT(.ZTMP,"INIT")
400;;>>?GPL(GPL(0))="FOURTH"
401;;>>>D POP^GPLXPATH("GPL",.GX)
402;;>>?GX="FOURTH"
403;;>>?GPL(GPL(0))="THIRD"
404;;>>>D POP^GPLXPATH("GPL",.GX)
405;;>>?GX="THIRD"
406;;>>?GPL(GPL(0))="SECOND"
407;;><MKMDX>
408;;>>>D ZLOAD^GPLUNIT("ZTMP","GPLXPATH")
409;;>>>D ZTEST^GPLUNIT(.ZTMP,"INIT")
410;;>>>S GX=""
411;;>>>D MKMDX^GPLXPATH("GPL",.GX)
412;;>>?GX="//FIRST/SECOND/THIRD/FOURTH"
413;;><XNAME>
414;;>>?$$XNAME^GPLXPATH("<FOURTH>DATA1</FOURTH>")="FOURTH"
415;;>>?$$XNAME^GPLXPATH("<SIXTH ID=""SELF"" />")="SIXTH"
416;;>>?$$XNAME^GPLXPATH("</THIRD>")="THIRD"
417;;><INDEX>
418;;>>>D ZLOAD^GPLUNIT("ZTMP","GPLXPATH")
419;;>>>D ZTEST^GPLUNIT(.ZTMP,"INITXML")
420;;>>>D INDEX^GPLXPATH("GXML")
421;;>>?GXML("//FIRST/SECOND")="2^12"
422;;>>?GXML("//FIRST/SECOND/THIRD")="3^9"
423;;>>?GXML("//FIRST/SECOND/THIRD/FIFTH")="5^7"
424;;>>?GXML("//FIRST/SECOND/THIRD/FOURTH")="4^4"
425;;>>?GXML("//FIRST/SECOND/THIRD/SIXTH")="8^8"
426;;>>?GXML("//FIRST/SECOND")="2^12"
427;;>>?GXML("//FIRST")="1^13"
428;;><INDEX2>
429;;>>>D ZTEST^GPLXPATH("INITXML2")
430;;>>>D INDEX^GPLXPATH("GXML")
431;;>>?GXML("//FIRST/SECOND")="2^12"
432;;>>?GXML("//FIRST/SECOND/_SECOND")="9^11"
433;;>>?GXML("//FIRST/SECOND/_SECOND/FOURTH")="10^10"
434;;>>?GXML("//FIRST/SECOND/THIRD")="3^8"
435;;>>?GXML("//FIRST/SECOND/THIRD/FOURTH")="4^7"
436;;>>?GXML("//FIRST")="1^13"
437;;><MISSING>
438;;>>>D ZTEST^GPLXPATH("INITXML")
439;;>>>S OUTARY="^TMP($J,""MISSINGTEST"")"
440;;>>>D MISSING^GPLXPATH("GXML",OUTARY)
441;;>>?@OUTARY@(1)="DATA1"
442;;>>?@OUTARY@(2)="DATA2"
443;;><MAP>
444;;>>>D ZTEST^GPLXPATH("INITXML")
445;;>>>S MAPARY="^TMP($J,""MAPVALUES"")"
446;;>>>S OUTARY="^TMP($J,""MAPTEST"")"
447;;>>>S @MAPARY@("DATA2")="VALUE2"
448;;>>>D MAP^GPLXPATH("GXML",MAPARY,OUTARY)
449;;>>?@OUTARY@(6)="VALUE2"
450;;><QUEUE>
451;;>>>D QUEUE^GPLXPATH("BTLIST","GXML",2,3)
452;;>>>D QUEUE^GPLXPATH("BTLIST","GXML",4,5)
453;;>>?$P(BTLIST(2),";",2)=4
454;;><BUILD>
455;;>>>D ZTEST^GPLXPATH("INITXML")
456;;>>>D QUERY^GPLXPATH("GXML","//FIRST/SECOND/THIRD/FOURTH","G2")
457;;>>>D ZTEST^GPLXPATH("QUEUE")
458;;>>>D BUILD^GPLXPATH("BTLIST","G3")
459;;><CP>
460;;>>>D ZTEST^GPLXPATH("INITXML")
461;;>>>D CP^GPLXPATH("GXML","G2")
462;;>>?G2(0)=13
463;;><QOPEN>
464;;>>>K G2,GBL
465;;>>>D ZTEST^GPLXPATH("INITXML")
466;;>>>D QOPEN^GPLXPATH("GBL","GXML")
467;;>>?$P(GBL(1),"^",3)=12
468;;>>>D BUILD^GPLXPATH("GBL","G2")
469;;>>?G2(G2(0))="</SECOND>"
470;;><QOPEN2>
471;;>>>K G2,GBL
472;;>>>D ZTEST^GPLXPATH("INITXML")
473;;>>>D QOPEN^GPLXPATH("GBL","GXML","//FIRST/SECOND")
474;;>>?$P(GBL(1),"^",3)=12
475;;>>>D BUILD^GPLXPATH("GBL","G2")
476;;>>?G2(G2(0))="</SECOND>"
477;;><QCLOSE>
478;;>>>K G2,GBL
479;;>>>D ZTEST^GPLXPATH("INITXML")
480;;>>>D QCLOSE^GPLXPATH("GBL","GXML")
481;;>>?$P(GBL(1),"^",3)=13
482;;>>>D BUILD^GPLXPATH("GBL","G2")
483;;>>?G2(G2(0))="</FIRST>"
484;;><QCLOSE2>
485;;>>>K G2,GBL
486;;>>>D ZTEST^GPLXPATH("INITXML")
487;;>>>D QCLOSE^GPLXPATH("GBL","GXML","//FIRST/SECOND/THIRD")
488;;>>?$P(GBL(1),"^",3)=13
489;;>>>D BUILD^GPLXPATH("GBL","G2")
490;;>>?G2(G2(0))="</FIRST>"
491;;>>?G2(1)="</THIRD>"
492;;><INSERT>
493;;>>>K G2,GBL,G3,G4
494;;>>>D ZTEST^GPLXPATH("INITXML")
495;;>>>D QUERY^GPLXPATH("GXML","//FIRST/SECOND/THIRD/FIFTH","G2")
496;;>>>D INSERT^GPLXPATH("GXML","G2","G3","//FIRST/SECOND/THIRD")
497;;>>>D INSERT^GPLXPATH("G3","G2","G4","//FIRST/SECOND/THIRD")
498;;>>?G2(1)=G3(9)
499;;><REPLACE>
500;;>>>K G2,GBL,G3
501;;>>>D ZTEST^GPLXPATH("INITXML")
502;;>>>D QUERY^GPLXPATH("GXML","//FIRST/SECOND/THIRD/FIFTH","G2")
503;;>>>D REPLACE^GPLXPATH("GXML","G2","//FIRST/SECOND")
504;;>>?GXML(3)="<FIFTH>"
505;;><INSINNER>
506;;>>>K GXML,G2,GBL,G3
507;;>>>D ZTEST^GPLXPATH("INITXML")
508;;>>>D QUERY^GPLXPATH("GXML","//FIRST/SECOND/THIRD","G2")
509;;>>>D INSINNER^GPLXPATH("GXML","G2","//FIRST/SECOND/THIRD")
510;;>>?GXML(10)="<FIFTH>"
511;;><INSINNER2>
512;;>>>K GXML,G2,GBL,G3
513;;>>>D ZTEST^GPLXPATH("INITXML")
514;;>>>D QUERY^GPLXPATH("GXML","//FIRST/SECOND/THIRD","G2")
515;;>>>D INSINNER^GPLXPATH("G2","G2")
516;;>>?G2(8)="<FIFTH>"
517;;></TEST>
Note: See TracBrowser for help on using the repository browser.