- Timestamp:
- Jul 14, 2009, 7:46:18 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
ccr/trunk/p/C0CXPATH.m
r531 r532 200 200 Q 201 201 ; 202 INDEX(IZXML,VDX,NOINX) ; parse the XML in IZXML and produce an XPATH index 202 INDEX(IZXML,VDX,NOINX,TEMPLATE) ; parse XML in IZXML and produce an XPATH index 203 ; GPL 7/14/09 OPTIONALLY GENERATE AN XML TEMPLATE IF PASSED BY NAME 204 ; TEMPLATE IS IDENTICAL TO THE PARSED XML LINE BY LINE 205 ; EXCEPT THAT DATA VALUES ARE REPLACED WITH @@XPATH@@ FOR THE XPATH OF THE TAG 203 206 ; GPL 5/24/09 AND OPTIONALLY PRODUCE THE VDX ARRAY PASSED BY NAME 204 207 ; @VDX@("XPATH")=VALUE … … 225 228 F I=1:1:LCNT D ; PROCESS THE ENTIRE ARRAY 226 229 . S LINE=@IZXML@(I) 230 . I $D(TEMPLATE) D ;IF TEMPLATE IS REQUESTED 231 . . S @TEMPLATE@(I)=$$CLEAN(LINE) 227 232 . ;W LINE,! 228 233 . S FOUND=0 ; INTIALIZED FOUND FLAG … … 250 255 . . . . S $P(@ZXML@(MDX),"^",3)=CURVAL ; THIRD PIECE 251 256 . . . . I DVDX S @VDX@(MDX)=CURVAL ; FILL IN VDX ARRAY IF REQUESTED 257 . . . . I $D(TEMPLATE) D ; IF TEMPLATE IS REQUESTED 258 . . . . . S LINE=$$CLEAN(LINE) ; CLEAN OUT CONTROL CHARACTERS 259 . . . . . S @TEMPLATE@(I)=$P(LINE,">",1)_">@@"_MDX_"@@</"_$P(LINE,"</",2) 252 260 . . . D POP("C0CSTK",.TMP) ; REMOVE FROM STACK 253 261 . I FOUND'=1 D ; THE LINE DOESN'T CONTAIN THE START AND END … … 280 288 Q 281 289 ; 290 CLEAN(STR) ; extrinsic function; returns string 291 ;; Removes all non printable characters from a string. 292 ;; STR by Value 293 N TR,I 294 F I=0:1:31 S TR=$G(TR)_$C(I) 295 S TR=TR_$C(127) 296 QUIT $TR(STR,TR) 297 ; 282 298 QUERY(IARY,XPATH,OARY) ; RETURNS THE XML ARRAY MATCHING THE XPATH EXPRESSION 283 299 ; XPATH IS OF THE FORM "//FIRST/SECOND/THIRD" … … 493 509 Q 494 510 ; 495 MAP(IXML,INARY,OXML) 511 MAP(IXML,INARY,OXML) ; SUBSTITUTE MULTIPLE @@X@@ VARS WITH VALUES IN INARY 496 512 ; AND PUT THE RESULTS IN OXML 497 I '$D(@IXML@(0)) W "MALFORMED XML PASSED TO MAP",! Q 513 N XCNT 514 I '$D(DEBUG) S DEBUG=0 515 I '$D(IXML) W "MALFORMED XML PASSED TO MAP",! Q 516 I '$D(@IXML@(0)) D ; INITIALIZE COUNT 517 . S XCNT=$O(@IXML@(""),-1) 518 E S XCNT=@IXML@(0) ;COUNT 498 519 I $O(@INARY@(""))="" W "EMPTY ARRAY PASSED TO MAP",! Q 499 520 N I,J,TNAM,TVAL,TSTR 500 S @OXML@(0)= @IXML@(0); TOTAL LINES IN OUTPUT501 F I=1:1: @OXML@(0)D ; LOOP THROUGH WHOLE ARRAY521 S @OXML@(0)=XCNT ; TOTAL LINES IN OUTPUT 522 F I=1:1:XCNT D ; LOOP THROUGH WHOLE ARRAY 502 523 . S @OXML@(I)=@IXML@(I) ; COPY THE LINE TO OUTPUT 503 524 . I @OXML@(I)?.E1"@@".E D ; IS THERE A VARIABLE HERE?
Note:
See TracChangeset
for help on using the changeset viewer.