- Timestamp:
- May 25, 2009, 2:37:55 PM (16 years ago)
- Location:
- ccr/trunk/p
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
ccr/trunk/p/C0CXPAT0.m
r508 r512 86 86 ;;>>?GXML("//FIRST/SECOND/THIRD")="3^9" 87 87 ;;>>?GXML("//FIRST/SECOND/THIRD/FIFTH")="5^7" 88 ;;>>?GXML("//FIRST/SECOND/THIRD/FOURTH")="4^4 "89 ;;>>?GXML("//FIRST/SECOND/THIRD/SIXTH")="8^8 "88 ;;>>?GXML("//FIRST/SECOND/THIRD/FOURTH")="4^4^@@DATA1@@" 89 ;;>>?GXML("//FIRST/SECOND/THIRD/SIXTH")="8^8^" 90 90 ;;>>?GXML("//FIRST/SECOND")="2^12" 91 91 ;;>>?GXML("//FIRST")="1^13" … … 95 95 ;;>>?GXML("//FIRST/SECOND")="2^12" 96 96 ;;>>?GXML("//FIRST/SECOND/_SECOND")="9^11" 97 ;;>>?GXML("//FIRST/SECOND/_SECOND/FOURTH")="10^10 "97 ;;>>?GXML("//FIRST/SECOND/_SECOND/FOURTH")="10^10^DATA3" 98 98 ;;>>?GXML("//FIRST/SECOND/THIRD")="3^8" 99 ;;>>?GXML("//FIRST/SECOND/THIRD/FOURTH")="4^7 "99 ;;>>?GXML("//FIRST/SECOND/THIRD/FOURTH")="4^7^DATA1" 100 100 ;;>>?GXML("//FIRST")="1^13" 101 101 ;;><MISSING> -
ccr/trunk/p/C0CXPATH.m
r508 r512 83 83 Q CUR 84 84 ; 85 INDEX(ZXML) ; parse the XML in ZXML and produce an XPATH index 86 ; ex. ZXML(FIRST,SECOND,THIRD,FOURTH)=FIRSTLINE^LASTLINE 85 XVAL(ISTR) ; EXTRACTS THE VALUE FROM A FRAGMENT OF XML 86 ; <NAME>VALUE</NAME> WILL RETURN VALUE 87 N G 88 S G=$P(ISTR,">",2) ;STRIP OFF <NAME> 89 Q $P(G,"<",1) ; STRIP OFF </NAME> LEAVING VALUE 90 ; 91 VDX2VDV(OUTVDV,INVDX) ; CONVERT AN VDX ARRAY TO VDV 92 ; VDX: @INVDX@(XPATH)=VALUE 93 ; VDV: @OUTVDV@(X1X2X3X4)=VALUE 94 ; THE VDV DATANAMES MIGHT BE MORE CONVENIENT FOR USE IN CODE 95 ; AN INDEX IS PROVIDED TO GO BACK TO VDX FOR CONVERSIONS 96 ; @VDV@("XPATH",X1X2X3X4)="XPATH" 97 N ZA,ZI,ZW 98 S ZI="" 99 F S ZI=$O(@INVDX@(ZI)) Q:ZI="" D ; 100 . S ZW=$TR(ZI,"/","") ; ELIMINATE ALL SLASHES - CAMEL CASE VARIABLE NAME 101 . W ZW,! 102 . S @OUTVDV@(ZW)=@INVDX@(ZI) 103 . S @OUTVDV@("XPATH",ZW)=ZI 104 Q 105 ; 106 VDX2XPG(OUTXPG,INVDX) ; CONVERT AN VDX ARRAY TO XPD 107 ; VDX: @VDX@(XPATH)=VALUE 108 ; XPG: @(VDX(X1,X2,X3,X4))@=VALUE 109 ; THIS IS A STEP TOWARD GENERATING XML FROM A VDX 110 N ZA,ZI,ZW 111 S ZI="" 112 F S ZI=$O(@INVDX@(ZI)) Q:ZI="" D ; 113 . S ZW=$E(ZI,3,$L(ZI)) ; STRIP OFF INITIAL // 114 . S ZW2=$P(ZW,"/",1) 115 . F ZK=1:1:$L(ZW,"/") D PUSH("ZA",$P(ZW,"/",ZK)) 116 . ZWR ZA 117 . S ZW2=ZA(1) 118 . F ZK=2:1:ZA(0) D ; 119 . . S ZW2=ZW2_""","""_ZA(ZK) 120 . K ZA 121 . S ZW2=""""_ZW2_"""" 122 . W ZW2,! 123 . S ZN=OUTXPG_"("_ZW2_")" 124 . S @ZN=@INVDX@(ZI) 125 Q 126 ; 127 INDEX(ZXML,VDX) ; parse the XML in ZXML and produce an XPATH index 128 ; GPL 5/24/09 AND OPTIONALLY PRODUCE THE VDX ARRAY PASSED BY NAME 129 ; @VDX@("XPATH")=VALUE 130 ; ex. @ZXML@("XPATH")=FIRSTLINE^LASTLINE 87 131 ; WHERE FIRSTLINE AND LASTLINE ARE THE BEGINNING AND ENDING OF THE 88 132 ; XML SECTION 89 133 ; ZXML IS PASSED BY NAME 90 N I,LINE,FIRST,LAST,CUR,TMP,MDX,FOUND 134 N I,LINE,FIRST,LAST,CUR,TMP,MDX,FOUND,CURVAL,DVDX,LCNT 91 135 N C0CSTK ; LEAVE OUT FOR DEBUGGING 92 I '$D(@ZXML@(0)) D ; NO XML PASSED 136 I '$D(@ZXML@(0)) D ; IF COUNT NOT IN NODE 0 COUNT THEM 137 . S I="",LCNT=0 138 . F S I=$O(@ZXML@(I)) Q:I="" S LCNT=LCNT+1 139 E S LCNT=@ZXML@(0) ; LINE COUNT PASSED IN ARRAY 140 I LCNT=0 D Q ; NO XML PASSED 93 141 . W "ERROR IN XML FILE",! 142 S DVDX=0 ; DEFAULT DO NOT PRODUCE VDX INDEX 143 I $D(VDX) S DVDX=1 ; IF NAME PASSED, DO VDX 94 144 S C0CSTK(0)=0 ; INITIALIZE STACK 95 F I=1:1: @ZXML@(0)D ; PROCESS THE ENTIRE ARRAY145 F I=1:1:LCNT D ; PROCESS THE ENTIRE ARRAY 96 146 . S LINE=@ZXML@(I) 97 147 . ;W LINE,! … … 112 162 . . . I '$D(@ZXML@(MDX)) D ; NOT IN THE INDEX, NOT A MULTIPLE 113 163 . . . . S @ZXML@(MDX)=I_"^"_I ; ADD INDEX ENTRY-FIRST AND LAST 164 . . . . S CURVAL=$$XVAL(LINE) ; VALUE 165 . . . . S $P(@ZXML@(MDX),"^",3)=CURVAL ; THIRD PIECE 166 . . . . I DVDX S @VDX@(MDX)=CURVAL ; FILL IN VDX ARRAY IF REQUESTED 114 167 . . . D POP("C0CSTK",.TMP) ; REMOVE FROM STACK 115 168 . I FOUND'=1 D ; THE LINE DOESN'T CONTAIN THE START AND END … … 138 191 . . . . S @ZXML@(MDX)=I_"^" ; INSERT INTO THE INDEX 139 192 S @ZXML@("INDEXED")="" 140 S @ZXML@("//")="1^"_ @ZXML@(0); ROOT XPATH193 S @ZXML@("//")="1^"_LCNT ; ROOT XPATH 141 194 Q 142 195 ;
Note:
See TracChangeset
for help on using the changeset viewer.