Changeset 532


Ignore:
Timestamp:
Jul 14, 2009, 7:46:18 PM (15 years ago)
Author:
George Lilly
Message:

features for eRx template processing

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ccr/trunk/p/C0CXPATH.m

    r531 r532  
    200200 Q
    201201 ;
    202 INDEX(IZXML,VDX,NOINX) ; parse the XML in IZXML and produce an XPATH index
     202INDEX(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
    203206 ; GPL 5/24/09 AND OPTIONALLY PRODUCE THE VDX ARRAY PASSED BY NAME
    204207 ; @VDX@("XPATH")=VALUE
     
    225228 F I=1:1:LCNT  D  ; PROCESS THE ENTIRE ARRAY
    226229 . S LINE=@IZXML@(I)
     230 . I $D(TEMPLATE) D  ;IF TEMPLATE IS REQUESTED
     231 . . S @TEMPLATE@(I)=$$CLEAN(LINE)
    227232 . ;W LINE,!
    228233 . S FOUND=0  ; INTIALIZED FOUND FLAG
     
    250255 . . . . S $P(@ZXML@(MDX),"^",3)=CURVAL ; THIRD PIECE
    251256 . . . . 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)
    252260 . . . D POP("C0CSTK",.TMP) ; REMOVE FROM STACK
    253261 . I FOUND'=1  D  ; THE LINE DOESN'T CONTAIN THE START AND END
     
    280288 Q
    281289 ;
     290CLEAN(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 ;
    282298QUERY(IARY,XPATH,OARY)   ; RETURNS THE XML ARRAY MATCHING THE XPATH EXPRESSION
    283299 ; XPATH IS OF THE FORM "//FIRST/SECOND/THIRD"
     
    493509 Q
    494510 ;
    495 MAP(IXML,INARY,OXML)      ; SUBSTITUTE MULTIPLE @@X@@ VARS WITH VALUES IN INARY
     511MAP(IXML,INARY,OXML) ; SUBSTITUTE MULTIPLE @@X@@ VARS WITH VALUES IN INARY
    496512 ; 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
    498519 I $O(@INARY@(""))="" W "EMPTY ARRAY PASSED TO MAP",! Q
    499520 N I,J,TNAM,TVAL,TSTR
    500  S @OXML@(0)=@IXML@(0) ; TOTAL LINES IN OUTPUT
    501  F I=1:1:@OXML@(0)  D   ; LOOP THROUGH WHOLE ARRAY
     521 S @OXML@(0)=XCNT ; TOTAL LINES IN OUTPUT
     522 F I=1:1:XCNT  D   ; LOOP THROUGH WHOLE ARRAY
    502523 . S @OXML@(I)=@IXML@(I) ; COPY THE LINE TO OUTPUT
    503524 . I @OXML@(I)?.E1"@@".E D  ; IS THERE A VARIABLE HERE?
Note: See TracChangeset for help on using the changeset viewer.