Changeset 124 for ccr/trunk/p
- Timestamp:
- Aug 31, 2008, 8:57:18 AM (16 years ago)
- Location:
- ccr/trunk/p
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
ccr/trunk/p/GPLXPATH.m
r98 r124 347 347 Q 348 348 ; 349 MAPOLD(IXML,INARY,OXML) ; SUBSTITUTE @@X@@ VARS IN IXML WITH VALUES IN INARY350 ; AND PUT THE RESULTS IN OXML351 I '$D(@IXML@(0)) W "MALFORMED XML PASSED TO MAP",! Q352 I $O(@INARY@(""))="" W "EMPTY ARRAY PASSED TO MAP",! Q353 N I,TNAM,TVAL354 S @OXML@(0)=@IXML@(0) ; TOTAL LINES IN OUTPUT355 F I=1:1:@OXML@(0) D ; LOOP THROUGH WHOLE ARRAY356 . S @OXML@(I)=@IXML@(I) ; COPY THE LINE TO OUTPUT357 . I @OXML@(I)?.E1"@@".E D ; IS THERE A VARIABLE HERE?358 . . S TNAM=$P(@OXML@(I),"@@",2) ; EXTRACT THE VARIABLE NAME359 . . I $D(@INARY@(TNAM)) D ; IS THE VARIABLE IN THE MAP?360 . . . S TVAL=@INARY@(TNAM) ; PULL OUT MAPPED VALUE361 . . . S @OXML@(I)=$P(@OXML@(I),"@@",1)_TVAL_$P(@OXML@(I),"@@",3)362 W "MAPPED",!363 Q364 ;365 349 MAP(IXML,INARY,OXML) ; SUBSTITUTE MULTIPLE @@X@@ VARS WITH VALUES IN INARY 366 350 ; AND PUT THE RESULTS IN OXML … … 437 421 ; 438 422 TEST ; Run all the test cases 439 D TESTALL^GPLUNIT("GPLXPATH") 440 Q 441 ; 442 OLDTEST ; RUN ALL THE TEST CASES 443 N ZTMP 444 D ZLOAD^GPLUNIT("ZTMP","GPLXPATH") 445 D ZTEST^GPLUNIT(.ZTMP,"ALL") 446 W "PASSED: ",TPASSED,! 447 W "FAILED: ",TFAILED,! 448 W ! 449 ; W "THE TESTS!",! 450 ; ZWR ZTMP 423 D TESTALL^GPLUNIT("GPLXPAT0") 451 424 Q 452 425 ; … … 454 427 N ZTMP 455 428 S DEBUG=1 456 D ZLOAD^GPLUNIT("ZTMP","GPLXPAT H")429 D ZLOAD^GPLUNIT("ZTMP","GPLXPAT0") 457 430 D ZTEST^GPLUNIT(.ZTMP,WHICH) 458 431 Q … … 460 433 TLIST ; LIST THE TESTS 461 434 N ZTMP 462 D ZLOAD^GPLUNIT("ZTMP","GPLXPAT H")435 D ZLOAD^GPLUNIT("ZTMP","GPLXPAT0") 463 436 D TLIST^GPLUNIT(.ZTMP) 464 437 Q 465 438 ; 466 ;;><TEST>467 ;;><INIT>468 ;;>>>K GPL S GPL=""469 ;;>>>D PUSH^GPLXPATH("GPL","FIRST")470 ;;>>>D PUSH^GPLXPATH("GPL","SECOND")471 ;;>>>D PUSH^GPLXPATH("GPL","THIRD")472 ;;>>>D PUSH^GPLXPATH("GPL","FOURTH")473 ;;>>?GPL(0)=4474 ;;><INITXML>475 ;;>>>K GXML S GXML=""476 ;;>>>D PUSH^GPLXPATH("GXML","<FIRST>")477 ;;>>>D PUSH^GPLXPATH("GXML","<SECOND>")478 ;;>>>D PUSH^GPLXPATH("GXML","<THIRD>")479 ;;>>>D PUSH^GPLXPATH("GXML","<FOURTH>@@DATA1@@</FOURTH>")480 ;;>>>D PUSH^GPLXPATH("GXML","<FIFTH>")481 ;;>>>D PUSH^GPLXPATH("GXML","@@DATA2@@")482 ;;>>>D PUSH^GPLXPATH("GXML","</FIFTH>")483 ;;>>>D PUSH^GPLXPATH("GXML","<SIXTH ID=""SELF"" />")484 ;;>>>D PUSH^GPLXPATH("GXML","</THIRD>")485 ;;>>>D PUSH^GPLXPATH("GXML","<SECOND>")486 ;;>>>D PUSH^GPLXPATH("GXML","</SECOND>")487 ;;>>>D PUSH^GPLXPATH("GXML","</SECOND>")488 ;;>>>D PUSH^GPLXPATH("GXML","</FIRST>")489 ;;><INITXML2>490 ;;>>>K GXML S GXML=""491 ;;>>>D PUSH^GPLXPATH("GXML","<FIRST>")492 ;;>>>D PUSH^GPLXPATH("GXML","<SECOND>")493 ;;>>>D PUSH^GPLXPATH("GXML","<THIRD>")494 ;;>>>D PUSH^GPLXPATH("GXML","<FOURTH>DATA1</FOURTH>")495 ;;>>>D PUSH^GPLXPATH("GXML","<FOURTH>")496 ;;>>>D PUSH^GPLXPATH("GXML","DATA2")497 ;;>>>D PUSH^GPLXPATH("GXML","</FOURTH>")498 ;;>>>D PUSH^GPLXPATH("GXML","</THIRD>")499 ;;>>>D PUSH^GPLXPATH("GXML","<_SECOND>")500 ;;>>>D PUSH^GPLXPATH("GXML","<FOURTH>DATA3</FOURTH>")501 ;;>>>D PUSH^GPLXPATH("GXML","</_SECOND>")502 ;;>>>D PUSH^GPLXPATH("GXML","</SECOND>")503 ;;>>>D PUSH^GPLXPATH("GXML","</FIRST>")504 ;;><PUSHPOP>505 ;;>>>D ZLOAD^GPLUNIT("ZTMP","GPLXPATH")506 ;;>>>D ZTEST^GPLUNIT(.ZTMP,"INIT")507 ;;>>?GPL(GPL(0))="FOURTH"508 ;;>>>D POP^GPLXPATH("GPL",.GX)509 ;;>>?GX="FOURTH"510 ;;>>?GPL(GPL(0))="THIRD"511 ;;>>>D POP^GPLXPATH("GPL",.GX)512 ;;>>?GX="THIRD"513 ;;>>?GPL(GPL(0))="SECOND"514 ;;><MKMDX>515 ;;>>>D ZLOAD^GPLUNIT("ZTMP","GPLXPATH")516 ;;>>>D ZTEST^GPLUNIT(.ZTMP,"INIT")517 ;;>>>S GX=""518 ;;>>>D MKMDX^GPLXPATH("GPL",.GX)519 ;;>>?GX="//FIRST/SECOND/THIRD/FOURTH"520 ;;><XNAME>521 ;;>>?$$XNAME^GPLXPATH("<FOURTH>DATA1</FOURTH>")="FOURTH"522 ;;>>?$$XNAME^GPLXPATH("<SIXTH ID=""SELF"" />")="SIXTH"523 ;;>>?$$XNAME^GPLXPATH("</THIRD>")="THIRD"524 ;;><INDEX>525 ;;>>>D ZLOAD^GPLUNIT("ZTMP","GPLXPATH")526 ;;>>>D ZTEST^GPLUNIT(.ZTMP,"INITXML")527 ;;>>>D INDEX^GPLXPATH("GXML")528 ;;>>?GXML("//FIRST/SECOND")="2^12"529 ;;>>?GXML("//FIRST/SECOND/THIRD")="3^9"530 ;;>>?GXML("//FIRST/SECOND/THIRD/FIFTH")="5^7"531 ;;>>?GXML("//FIRST/SECOND/THIRD/FOURTH")="4^4"532 ;;>>?GXML("//FIRST/SECOND/THIRD/SIXTH")="8^8"533 ;;>>?GXML("//FIRST/SECOND")="2^12"534 ;;>>?GXML("//FIRST")="1^13"535 ;;><INDEX2>536 ;;>>>D ZTEST^GPLXPATH("INITXML2")537 ;;>>>D INDEX^GPLXPATH("GXML")538 ;;>>?GXML("//FIRST/SECOND")="2^12"539 ;;>>?GXML("//FIRST/SECOND/_SECOND")="9^11"540 ;;>>?GXML("//FIRST/SECOND/_SECOND/FOURTH")="10^10"541 ;;>>?GXML("//FIRST/SECOND/THIRD")="3^8"542 ;;>>?GXML("//FIRST/SECOND/THIRD/FOURTH")="4^7"543 ;;>>?GXML("//FIRST")="1^13"544 ;;><MISSING>545 ;;>>>D ZTEST^GPLXPATH("INITXML")546 ;;>>>S OUTARY="^TMP($J,""MISSINGTEST"")"547 ;;>>>D MISSING^GPLXPATH("GXML",OUTARY)548 ;;>>?@OUTARY@(1)="DATA1"549 ;;>>?@OUTARY@(2)="DATA2"550 ;;><MAP>551 ;;>>>D ZTEST^GPLXPATH("INITXML")552 ;;>>>S MAPARY="^TMP($J,""MAPVALUES"")"553 ;;>>>S OUTARY="^TMP($J,""MAPTEST"")"554 ;;>>>S @MAPARY@("DATA2")="VALUE2"555 ;;>>>D MAP^GPLXPATH("GXML",MAPARY,OUTARY)556 ;;>>?@OUTARY@(6)="VALUE2"557 ;;><MAP2>558 ;;>>>D ZTEST^GPLXPATH("INITXML")559 ;;>>>S MAPARY="^TMP($J,""MAPVALUES"")"560 ;;>>>S OUTARY="^TMP($J,""MAPTEST"")"561 ;;>>>S @MAPARY@("DATA1")="VALUE1"562 ;;>>>S @MAPARY@("DATA2")="VALUE2"563 ;;>>>S @MAPARY@("DATA3")="VALUE3"564 ;;>>>S GXML(4)="<FOURTH>@@DATA1@@ AND @@DATA3@@</FOURTH>"565 ;;>>>D MAP^GPLXPATH("GXML",MAPARY,OUTARY)566 ;;>>>D PARY^GPLXPATH(OUTARY)567 ;;>>?@OUTARY@(4)="<FOURTH>VALUE1 AND VALUE3</FOURTH>"568 ;;><QUEUE>569 ;;>>>D QUEUE^GPLXPATH("BTLIST","GXML",2,3)570 ;;>>>D QUEUE^GPLXPATH("BTLIST","GXML",4,5)571 ;;>>?$P(BTLIST(2),";",2)=4572 ;;><BUILD>573 ;;>>>D ZTEST^GPLXPATH("INITXML")574 ;;>>>D QUERY^GPLXPATH("GXML","//FIRST/SECOND/THIRD/FOURTH","G2")575 ;;>>>D ZTEST^GPLXPATH("QUEUE")576 ;;>>>D BUILD^GPLXPATH("BTLIST","G3")577 ;;><CP>578 ;;>>>D ZTEST^GPLXPATH("INITXML")579 ;;>>>D CP^GPLXPATH("GXML","G2")580 ;;>>?G2(0)=13581 ;;><QOPEN>582 ;;>>>K G2,GBL583 ;;>>>D ZTEST^GPLXPATH("INITXML")584 ;;>>>D QOPEN^GPLXPATH("GBL","GXML")585 ;;>>?$P(GBL(1),";",3)=12586 ;;>>>D BUILD^GPLXPATH("GBL","G2")587 ;;>>?G2(G2(0))="</SECOND>"588 ;;><QOPEN2>589 ;;>>>K G2,GBL590 ;;>>>D ZTEST^GPLXPATH("INITXML")591 ;;>>>D QOPEN^GPLXPATH("GBL","GXML","//FIRST/SECOND")592 ;;>>?$P(GBL(1),";",3)=11593 ;;>>>D BUILD^GPLXPATH("GBL","G2")594 ;;>>?G2(G2(0))="</SECOND>"595 ;;><QCLOSE>596 ;;>>>K G2,GBL597 ;;>>>D ZTEST^GPLXPATH("INITXML")598 ;;>>>D QCLOSE^GPLXPATH("GBL","GXML")599 ;;>>?$P(GBL(1),";",3)=13600 ;;>>>D BUILD^GPLXPATH("GBL","G2")601 ;;>>?G2(G2(0))="</FIRST>"602 ;;><QCLOSE2>603 ;;>>>K G2,GBL604 ;;>>>D ZTEST^GPLXPATH("INITXML")605 ;;>>>D QCLOSE^GPLXPATH("GBL","GXML","//FIRST/SECOND/THIRD")606 ;;>>?$P(GBL(1),";",3)=13607 ;;>>>D BUILD^GPLXPATH("GBL","G2")608 ;;>>?G2(G2(0))="</FIRST>"609 ;;>>?G2(1)="</THIRD>"610 ;;><INSERT>611 ;;>>>K G2,GBL,G3,G4612 ;;>>>D ZTEST^GPLXPATH("INITXML")613 ;;>>>D QUERY^GPLXPATH("GXML","//FIRST/SECOND/THIRD/FIFTH","G2")614 ;;>>>D INSERT^GPLXPATH("GXML","G2","//FIRST/SECOND/THIRD")615 ;;>>>D INSERT^GPLXPATH("G3","G2","//")616 ;;>>?G2(1)=GXML(9)617 ;;><REPLACE>618 ;;>>>K G2,GBL,G3619 ;;>>>D ZTEST^GPLXPATH("INITXML")620 ;;>>>D QUERY^GPLXPATH("GXML","//FIRST/SECOND/THIRD/FIFTH","G2")621 ;;>>>D REPLACE^GPLXPATH("GXML","G2","//FIRST/SECOND")622 ;;>>?GXML(2)="<FIFTH>"623 ;;><INSINNER>624 ;;>>>K GXML,G2,GBL,G3625 ;;>>>D ZTEST^GPLXPATH("INITXML")626 ;;>>>D QUERY^GPLXPATH("GXML","//FIRST/SECOND/THIRD","G2")627 ;;>>>D INSINNER^GPLXPATH("GXML","G2","//FIRST/SECOND/THIRD")628 ;;>>?GXML(10)="<FIFTH>"629 ;;><INSINNER2>630 ;;>>>K GXML,G2,GBL,G3631 ;;>>>D ZTEST^GPLXPATH("INITXML")632 ;;>>>D QUERY^GPLXPATH("GXML","//FIRST/SECOND/THIRD","G2")633 ;;>>>D INSINNER^GPLXPATH("G2","G2")634 ;;>>?G2(8)="<FIFTH>"635 ;;></TEST>
Note:
See TracChangeset
for help on using the changeset viewer.