- Timestamp:
- Sep 8, 2009, 8:29:22 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
ccr/trunk/p/C0CXPATH.m
r532 r557 226 226 I $D(VDX) S DVDX=1 ; IF NAME PASSED, DO VDX 227 227 S C0CSTK(0)=0 ; INITIALIZE STACK 228 D MKLASD(.LKASD,IZXML) ;MAKE LOOK ASIDE BUFFER FOR MULTIPLES 228 229 F I=1:1:LCNT D ; PROCESS THE ENTIRE ARRAY 229 230 . S LINE=@IZXML@(I) … … 240 241 . . . S FOUND=1 ; SET FOUND FLAG 241 242 . . . S CUR=$$XNAME(LINE) ; EXTRACT THE NAME 243 . . . S CUR=CUR_$G(LKASD(CUR,I)) ; HANDLE MULTIPLES 242 244 . . . D PUSH("C0CSTK",CUR) ; ADD TO THE STACK 243 245 . . . D MKMDX("C0CSTK",.MDX) ; GENERATE THE M INDEX … … 267 269 . . . S $P(@ZXML@(MDX),"^",2)=I ; UPDATE LAST LINE NUMBER 268 270 . . . D POP("C0CSTK",.TMP) ; REMOVE FROM STACK 271 . . . S TMP=$P(TMP,"[",1) ; REMOVE [X] FROM MULTIPLE 269 272 . . . I TMP'=CUR D ; MALFORMED XML, END MUST MATCH START 270 273 . . . . W "MALFORMED XML ",CUR,"LINE "_I_LINE,! … … 276 279 . . . S FOUND=1 ; SET FOUND FLAG 277 280 . . . S CUR=$$XNAME(LINE) ; EXTRACT THE NAME 281 . . . S CUR=CUR_$G(LKASD(CUR,I)) ; HANDLE MULTIPLES 278 282 . . . D PUSH("C0CSTK",CUR) ; ADD TO THE STACK 279 283 . . . D MKMDX("C0CSTK",.MDX) ; GENERATE THE M INDEX … … 281 285 . . . I $D(@ZXML@(MDX)) D ; IN THE INDEX, IS A MULTIPLE 282 286 . . . . S $P(@ZXML@(MDX),"^",2)=I ; UPDATE LAST LINE NUMBER 287 . . . . ;B 283 288 . . . I '$D(@ZXML@(MDX)) D ; NOT IN THE INDEX, NOT A MULTIPLE 284 289 . . . . S @ZXML@(MDX)=I_"^" ; INSERT INTO THE INDEX … … 286 291 S @ZXML@("//")="1^"_LCNT ; ROOT XPATH 287 292 I NOINX K @ZXML ; DELETE UNWANTED INDEX 293 Q 294 ; 295 MKLASD(OUTBUF,INARY) ; CREATE A LOOKASIDE BUFFER FOR MULTILPLES 296 ; 297 N ZI,ZN,ZA,ZLINE,ZLINE2,CUR,CUR2 298 F ZI=1:1:LCNT-1 D ; PROCESS THE ENTIRE ARRAY 299 . S ZLINE=@IZXML@(ZI) 300 . I ZI<LCNT S ZLINE2=@IZXML@(ZI+1) 301 . I ZLINE?.E1"</"1.E D ; NEXT LINE CONTAINS END OF A SECTION 302 . . S CUR=$$XNAME(ZLINE) ; EXTRACT THE NAME 303 . . I (ZLINE2?.E1"<"1.E)&(ZLINE'["?>") D ; BEGINNING OF A SECTION 304 . . . S CUR2=$$XNAME(ZLINE2) ; EXTRACT THE NAME 305 . . . I CUR=CUR2 D ; IF THIS IS A MULTIPLE 306 . . . . S OUTBUF(CUR,ZI+1)="" 307 ;ZWR OUTBUF 308 S ZI="" 309 F S ZI=$O(OUTBUF(ZI)) Q:ZI="" D ; FOR EACH KIND OF MULTIPLE 310 . S ZN=$O(OUTBUF(ZI,"")) ; LINE NUMBER OF SECOND MULTIPLE 311 . F S ZN=$O(@IZXML@(ZN),-1) Q:ZN="" I $P(@IZXML@(ZN),"<"_ZI,2)=">" Q ; 312 . S OUTBUF(ZI,ZN)="" 313 S ZA=1,ZI="",ZN="" 314 F S ZI=$O(OUTBUF(ZI)) Q:ZI="" D ; ADDING THE COUNT FOR THE MULIPLES [x] 315 . S ZN="",ZA=1 316 . F S ZN=$O(OUTBUF(ZI,ZN)) Q:ZN="" D ; 317 . . S OUTBUF(ZI,ZN)="["_ZA_"]" 318 . . S ZA=ZA+1 288 319 Q 289 320 ;
Note:
See TracChangeset
for help on using the changeset viewer.