Changeset 76 for ccr/trunk/p/GPLXPATH.m
- Timestamp:
- Jul 27, 2008, 4:37:10 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
ccr/trunk/p/GPLXPATH.m
r75 r76 299 299 Q 300 300 ; 301 INSB4(XDEST,XNEW) ; INSERT XNEW AT THE BEGINNING OF XDEST 302 ; BUT XDEST AN XNEW ARE PASSED BY NAME 303 N XBLD,XTMP 304 D QUEUE("XBLD",XDEST,1,1) ; NEED TO PRESERVE SECTION ROOT 305 D QUEUE("XBLD",XNEW,1,@XNEW@(0)) ; ALL OF NEW XML FIRST 306 D QUEUE("XBLD",XDEST,2,@XDEST@(0)) ; FOLLOWED BY THE REST OF SECTION 307 D BUILD("XBLD","XTMP") ; BUILD THE RESULT 308 D CP("XTMP",XDEST) ; COPY TO THE DESTINATION 309 I DEBUG D PARY("XDEST") 310 Q 311 ; 301 312 REPLACE(REXML,RENEW,REXPATH) ; REPLACE THE XML AT THE XPATH POINT 302 313 ; WITH RENEW - NOTE THIS WILL DELETE WHAT WAS THERE BEFORE … … 362 373 . . S TSTR=$P(@IXML@(I),"@@",1) ; INIT TO PART BEFORE VARS 363 374 . . F J=2:2:10 D Q:$P(@IXML@(I),"@@",J+2)="" ; QUIT IF NO MORE VARS 364 . . . W "IN MAPPING LOOP: ",TSTR,!375 . . . I DEBUG W "IN MAPPING LOOP: ",TSTR,! 365 376 . . . S TNAM=$P(@OXML@(I),"@@",J) ; EXTRACT THE VARIABLE NAME 366 377 . . . S TVAL="@@"_$P(@IXML@(I),"@@",J)_"@@" ; DEFAULT UNCHANGED … … 369 380 . . . S TSTR=TSTR_TVAL_$P(@IXML@(I),"@@",J+1) ; ADD VAR AND PART AFTER 370 381 . . S @OXML@(I)=TSTR ; COPY LINE WITH MAPPED VALUES 371 . . W TSTR382 . . I DEBUG W TSTR 372 383 W "MAPPED",! 373 384 Q … … 375 386 TRIM(THEXML) ; TAKES OUT ALL NULL ELEMENTS 376 387 ; THEXML IS PASSED BY NAME 377 N I,J,TMPXML,DEL,FOUND 388 N I,J,TMPXML,DEL,FOUND,INTXT 378 389 S FOUND=0 390 S INTXT=0 379 391 W "DELETING EMPTY ELEMENTS",! 380 392 F I=1:1:(@THEXML@(0)-1) D ; LOOP THROUGH ENTIRE ARRAY 381 393 . S J=@THEXML@(I) 394 . I J["<text>" D 395 . . S INTXT=1 ; IN HTML SECTION, DON'T TRIM 396 . . W "IN HTML SECTION",! 382 397 . N JM,JP ; JMINUS AND JPLUS 383 398 . S JM=@THEXML@(I-1) ; LINE BEFORE 399 . I JM["</text>" S INTXT=0 ; LEFT HTML SECTION,START TRIM 384 400 . S JP=@THEXML@(I+1) ; LINE AFTER 385 . S JPX=$TR(JP,"/","") ; REMOVE THE SLASH 386 . I J=JPX D ; AN EMPTY ELEMENT ON TWO LINES 387 . . W I,J,JP,! 388 . . S FOUND=1 ; FOUND SOMETHING TO BE DELETED 389 . . S DEL(I)="" ; SET LINE TO DELETE 390 . . S DEL(I+1)="" ; SET NEXT LINE TO DELETE 391 . I J["><" D ; AN EMPTY ELEMENT ON ONE LINE 392 . . W I,J,! 393 . . S FOUND=1 ; FOUND SOMETHING TO BE DELETED 394 . . S DEL(I)="" ; SET THE EMPTY LINE UP TO BE DELETED 395 . . I JM=JPX D ; 396 . . . W I,JM_J_JPX,! 397 . . . S DEL(I-1)="" 398 . . . S DEL(I+1)="" ; SET THE SURROUNDING LINES FOR DEL 401 . I INTXT=0 D ; IF NOT IN AN HTML SECTION 402 . . S JPX=$TR(JP,"/","") ; REMOVE THE SLASH 403 . . I J=JPX D ; AN EMPTY ELEMENT ON TWO LINES 404 . . . W I,J,JP,! 405 . . . S FOUND=1 ; FOUND SOMETHING TO BE DELETED 406 . . . S DEL(I)="" ; SET LINE TO DELETE 407 . . . S DEL(I+1)="" ; SET NEXT LINE TO DELETE 408 . . I J["><" D ; AN EMPTY ELEMENT ON ONE LINE 409 . . . W I,J,! 410 . . . S FOUND=1 ; FOUND SOMETHING TO BE DELETED 411 . . . S DEL(I)="" ; SET THE EMPTY LINE UP TO BE DELETED 412 . . . I JM=JPX D ; 413 . . . . W I,JM_J_JPX,! 414 . . . . S DEL(I-1)="" 415 . . . . S DEL(I+1)="" ; SET THE SURROUNDING LINES FOR DEL 399 416 ; . I J'["><" D PUSH("TMPXML",J) 400 417 I FOUND D ; NEED TO DELETE THINGS … … 405 422 Q FOUND 406 423 ; 424 UNMARK(XSEC) ; REMOVE MARKUP FROM FIRST AND LAST LINE OF XML 425 ; XSEC IS A SECTION PASSED BY NAME 426 N XBLD,XTMP 427 D QUEUE("XBLD",XSEC,2,@XSEC@(0)-1) ; BUILD LIST FOR INNER XML 428 D BUILD("XBLD","XTMP") ; BUILD THE RESULT 429 D CP("XTMP",XSEC) ; REPLACE PASSED XML 430 Q 431 ; 407 432 PARY(GLO) ;PRINT AN ARRAY 408 433 N I
Note:
See TracChangeset
for help on using the changeset viewer.