addition of multiples in XPATH generation
This commit is contained in:
parent
d1c8a53a02
commit
1dbbb222bf
31
p/C0CXPATH.m
31
p/C0CXPATH.m
|
@ -225,6 +225,7 @@ INDEX(IZXML,VDX,NOINX,TEMPLATE) ; parse XML in IZXML and produce an XPATH index
|
||||||
S DVDX=0 ; DEFAULT DO NOT PRODUCE VDX INDEX
|
S DVDX=0 ; DEFAULT DO NOT PRODUCE VDX INDEX
|
||||||
I $D(VDX) S DVDX=1 ; IF NAME PASSED, DO VDX
|
I $D(VDX) S DVDX=1 ; IF NAME PASSED, DO VDX
|
||||||
S C0CSTK(0)=0 ; INITIALIZE STACK
|
S C0CSTK(0)=0 ; INITIALIZE STACK
|
||||||
|
D MKLASD(.LKASD,IZXML) ;MAKE LOOK ASIDE BUFFER FOR MULTIPLES
|
||||||
F I=1:1:LCNT D ; PROCESS THE ENTIRE ARRAY
|
F I=1:1:LCNT D ; PROCESS THE ENTIRE ARRAY
|
||||||
. S LINE=@IZXML@(I)
|
. S LINE=@IZXML@(I)
|
||||||
. I $D(TEMPLATE) D ;IF TEMPLATE IS REQUESTED
|
. I $D(TEMPLATE) D ;IF TEMPLATE IS REQUESTED
|
||||||
|
@ -239,6 +240,7 @@ INDEX(IZXML,VDX,NOINX,TEMPLATE) ; parse XML in IZXML and produce an XPATH index
|
||||||
. . . ; W "FOUND ",LINE,!
|
. . . ; W "FOUND ",LINE,!
|
||||||
. . . S FOUND=1 ; SET FOUND FLAG
|
. . . S FOUND=1 ; SET FOUND FLAG
|
||||||
. . . S CUR=$$XNAME(LINE) ; EXTRACT THE NAME
|
. . . S CUR=$$XNAME(LINE) ; EXTRACT THE NAME
|
||||||
|
. . . S CUR=CUR_$G(LKASD(CUR,I)) ; HANDLE MULTIPLES
|
||||||
. . . D PUSH("C0CSTK",CUR) ; ADD TO THE STACK
|
. . . D PUSH("C0CSTK",CUR) ; ADD TO THE STACK
|
||||||
. . . D MKMDX("C0CSTK",.MDX) ; GENERATE THE M INDEX
|
. . . D MKMDX("C0CSTK",.MDX) ; GENERATE THE M INDEX
|
||||||
. . . ; W "MDX=",MDX,!
|
. . . ; W "MDX=",MDX,!
|
||||||
|
@ -266,6 +268,7 @@ INDEX(IZXML,VDX,NOINX,TEMPLATE) ; parse XML in IZXML and produce an XPATH index
|
||||||
. . . D MKMDX("C0CSTK",.MDX) ; GENERATE THE M INDEX
|
. . . D MKMDX("C0CSTK",.MDX) ; GENERATE THE M INDEX
|
||||||
. . . S $P(@ZXML@(MDX),"^",2)=I ; UPDATE LAST LINE NUMBER
|
. . . S $P(@ZXML@(MDX),"^",2)=I ; UPDATE LAST LINE NUMBER
|
||||||
. . . D POP("C0CSTK",.TMP) ; REMOVE FROM STACK
|
. . . D POP("C0CSTK",.TMP) ; REMOVE FROM STACK
|
||||||
|
. . . S TMP=$P(TMP,"[",1) ; REMOVE [X] FROM MULTIPLE
|
||||||
. . . I TMP'=CUR D ; MALFORMED XML, END MUST MATCH START
|
. . . I TMP'=CUR D ; MALFORMED XML, END MUST MATCH START
|
||||||
. . . . W "MALFORMED XML ",CUR,"LINE "_I_LINE,!
|
. . . . W "MALFORMED XML ",CUR,"LINE "_I_LINE,!
|
||||||
. . . . D PARY("C0CSTK") ; PRINT OUT THE STACK FOR DEBUGING
|
. . . . D PARY("C0CSTK") ; PRINT OUT THE STACK FOR DEBUGING
|
||||||
|
@ -275,11 +278,13 @@ INDEX(IZXML,VDX,NOINX,TEMPLATE) ; parse XML in IZXML and produce an XPATH index
|
||||||
. . . ; W "FOUND ",LINE,!
|
. . . ; W "FOUND ",LINE,!
|
||||||
. . . S FOUND=1 ; SET FOUND FLAG
|
. . . S FOUND=1 ; SET FOUND FLAG
|
||||||
. . . S CUR=$$XNAME(LINE) ; EXTRACT THE NAME
|
. . . S CUR=$$XNAME(LINE) ; EXTRACT THE NAME
|
||||||
|
. . . S CUR=CUR_$G(LKASD(CUR,I)) ; HANDLE MULTIPLES
|
||||||
. . . D PUSH("C0CSTK",CUR) ; ADD TO THE STACK
|
. . . D PUSH("C0CSTK",CUR) ; ADD TO THE STACK
|
||||||
. . . D MKMDX("C0CSTK",.MDX) ; GENERATE THE M INDEX
|
. . . D MKMDX("C0CSTK",.MDX) ; GENERATE THE M INDEX
|
||||||
. . . ; W "MDX=",MDX,!
|
. . . ; W "MDX=",MDX,!
|
||||||
. . . I $D(@ZXML@(MDX)) D ; IN THE INDEX, IS A MULTIPLE
|
. . . I $D(@ZXML@(MDX)) D ; IN THE INDEX, IS A MULTIPLE
|
||||||
. . . . S $P(@ZXML@(MDX),"^",2)=I ; UPDATE LAST LINE NUMBER
|
. . . . S $P(@ZXML@(MDX),"^",2)=I ; UPDATE LAST LINE NUMBER
|
||||||
|
. . . . ;B
|
||||||
. . . I '$D(@ZXML@(MDX)) D ; NOT IN THE INDEX, NOT A MULTIPLE
|
. . . I '$D(@ZXML@(MDX)) D ; NOT IN THE INDEX, NOT A MULTIPLE
|
||||||
. . . . S @ZXML@(MDX)=I_"^" ; INSERT INTO THE INDEX
|
. . . . S @ZXML@(MDX)=I_"^" ; INSERT INTO THE INDEX
|
||||||
S @ZXML@("INDEXED")=""
|
S @ZXML@("INDEXED")=""
|
||||||
|
@ -287,6 +292,32 @@ INDEX(IZXML,VDX,NOINX,TEMPLATE) ; parse XML in IZXML and produce an XPATH index
|
||||||
I NOINX K @ZXML ; DELETE UNWANTED INDEX
|
I NOINX K @ZXML ; DELETE UNWANTED INDEX
|
||||||
Q
|
Q
|
||||||
;
|
;
|
||||||
|
MKLASD(OUTBUF,INARY) ; CREATE A LOOKASIDE BUFFER FOR MULTILPLES
|
||||||
|
;
|
||||||
|
N ZI,ZN,ZA,ZLINE,ZLINE2,CUR,CUR2
|
||||||
|
F ZI=1:1:LCNT-1 D ; PROCESS THE ENTIRE ARRAY
|
||||||
|
. S ZLINE=@IZXML@(ZI)
|
||||||
|
. I ZI<LCNT S ZLINE2=@IZXML@(ZI+1)
|
||||||
|
. I ZLINE?.E1"</"1.E D ; NEXT LINE CONTAINS END OF A SECTION
|
||||||
|
. . S CUR=$$XNAME(ZLINE) ; EXTRACT THE NAME
|
||||||
|
. . I (ZLINE2?.E1"<"1.E)&(ZLINE'["?>") D ; BEGINNING OF A SECTION
|
||||||
|
. . . S CUR2=$$XNAME(ZLINE2) ; EXTRACT THE NAME
|
||||||
|
. . . I CUR=CUR2 D ; IF THIS IS A MULTIPLE
|
||||||
|
. . . . S OUTBUF(CUR,ZI+1)=""
|
||||||
|
;ZWR OUTBUF
|
||||||
|
S ZI=""
|
||||||
|
F S ZI=$O(OUTBUF(ZI)) Q:ZI="" D ; FOR EACH KIND OF MULTIPLE
|
||||||
|
. S ZN=$O(OUTBUF(ZI,"")) ; LINE NUMBER OF SECOND MULTIPLE
|
||||||
|
. F S ZN=$O(@IZXML@(ZN),-1) Q:ZN="" I $P(@IZXML@(ZN),"<"_ZI,2)=">" Q ;
|
||||||
|
. S OUTBUF(ZI,ZN)=""
|
||||||
|
S ZA=1,ZI="",ZN=""
|
||||||
|
F S ZI=$O(OUTBUF(ZI)) Q:ZI="" D ; ADDING THE COUNT FOR THE MULIPLES [x]
|
||||||
|
. S ZN="",ZA=1
|
||||||
|
. F S ZN=$O(OUTBUF(ZI,ZN)) Q:ZN="" D ;
|
||||||
|
. . S OUTBUF(ZI,ZN)="["_ZA_"]"
|
||||||
|
. . S ZA=ZA+1
|
||||||
|
Q
|
||||||
|
;
|
||||||
CLEAN(STR) ; extrinsic function; returns string
|
CLEAN(STR) ; extrinsic function; returns string
|
||||||
;; Removes all non printable characters from a string.
|
;; Removes all non printable characters from a string.
|
||||||
;; STR by Value
|
;; STR by Value
|
||||||
|
|
Loading…
Reference in New Issue