Changeset 1204 for ccr/trunk/p/C0CDOM.m
- Timestamp:
- Jun 23, 2011, 3:01:41 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
ccr/trunk/p/C0CDOM.m
r1203 r1204 126 126 Q 127 127 ; 128 OUTXML(ZRTN,INID ) ; USES C0CMXMLB (MXMLBLD) TO OUTPUT XML FROM AN MXMLDOM128 OUTXML(ZRTN,INID,NO1ST) ; USES C0CMXMLB (MXMLBLD) TO OUTPUT XML FROM AN MXMLDOM 129 129 ; 130 130 S C0CDOCID=INID 131 D START^C0CMXMLB($$TAG(1),,"G") 131 I '$D(NO1ST) S NO1ST=0 ; DO NOT SURPRESS THE <?xml tag generation 132 D START^C0CMXMLB($$TAG(1),,"G",NO1ST) 132 133 D NDOUT($$FIRST(1)) 133 134 D END^C0CMXMLB ;END THE DOCUMENT … … 156 157 S GN2=$NA(@GN@(1)) 157 158 W $$OUTPUT^C0CXPATH(GN2,"nhin_"_ZDFN_".xml","/home/wvehr3-09/") 159 Q 160 ; 161 NARY2XML(ZGOUT,ZGIN) ; CREATE XML FROM AN NHIN ARRAY 162 ; ZGOUT AND ZGIN ARE PASSED BY NAME 163 N C0CDOCID 164 W !,ZGOUT," ",ZGIN 165 S C0CDOCID=$$DOMI(ZGIN) ; PUT IT INTO THE DOM 166 D OUTXML(ZGOUT,C0CDOCID) 158 167 Q 159 168 ; … … 217 226 I '$D(INARY) Q 0 ; NO ARRAY PASSED 218 227 I '$D(HANDLE) S HANDLE=$$NEWDOM() ; MAKE A NEW DOM 228 ;I PARENT="" S PARENT="root" 219 229 I +$G(PARENT)>0 S ZPARNODE=PARENT ; WE HAVE BEEN PASSED A PARENT NODE ID 220 E I $L( PARENT)>0 D ; TBD FIND THE PARENT IN THE DOM AND SET LEVEL230 E I $L($G(PARENT))>0 D ; TBD FIND THE PARENT IN THE DOM AND SET LEVEL 221 231 . D STARTELE^MXMLDOM(PARENT) ; INSERT THE PARENT NODE 222 232 . S ZPARNODE=1 ; 223 233 ; WE NOW HAVE A HANDLE AND A PARENT NODE AND LEVEL HAS BEEN SET 224 D MAJOR(INARY,"",0) ; PROCESS ALL THE NODES TO BE ADDED 225 I $L(PARENT)>0 D ENDELE^MXMLDOM(PARENT) ; CLOSE OUT THE PARENT NODE 226 Q 1 ; SUCCESS 234 N ZEXARY 235 D EXPAND("ZEXARY",INARY) ; EXPAND THE NHIN ARRAY 236 D MAJOR("ZEXARY") ; PROCESS ALL THE NODES TO BE ADDED 237 I $L($G(PARENT))>0 D ENDELE^MXMLDOM(PARENT) ; CLOSE OUT THE PARENT NODE 238 Q HANDLE ; SUCCESS 227 239 ; 228 MAJOR(ZARY ,ZTAG,ZNUM) ; RECURSIVE ROUTINE FOR INTERMEDIATE NODES240 MAJOR(ZARY) ; RECURSIVE ROUTINE FOR INTERMEDIATE NODES 229 241 N ZI S ZI="" 242 N ZTAG 230 243 F S ZI=$O(@ZARY@(ZI)) Q:ZI="" D ; FOR EACH SECTION 244 . N ZELEADD S ZELEADD=0 245 . I ZI["@" D ; END NODE HAS NO VALUE, ONLY ATTRIBUTES 246 . . S ZTAG=$P(ZI,"@",1) ; PULL OUT THE TAG 247 . . K ZATT ; CLEAR OUT LAST ONE 248 . . M ZATT=@ZARY@(ZI,1) ; GET ATTRIBUTE ARRAY 249 . . D STARTELE^MXMLDOM(ZTAG,.ZATT) ; ADD THE NODE 250 . . S ZELEADD=1 ; FLAG TO NOT ADD THE ELEMENT TWICE 251 . I $O(@ZARY@(ZI,""))="" D ;END NODE 252 . . S ZTAG=ZI ; USE ZI FOR THE TAG 253 . . I 'ZELEADD D STARTELE^MXMLDOM(ZTAG) ; ADD ELEMENT IF NOT THERE 254 . . S ZELEADD=1 ; ADDED AN ELEMENT 255 . . D CHAR^MXMLDOM($G(@ZARY@(ZI))) ; INSERT THE VALUE 256 . I ZELEADD D Q ; NO MORE TO DO ON THIS LEVEL 257 . . D ENDELE^MXMLDOM(ZTAG) ; CLOSE THE ELEMENT BEFORE LEAVING 258 . N NEWARY ; INDENTED ARRAY 231 259 . N ZN S ZN=0 232 260 . F S ZN=$O(@ZARY@(ZI,ZN)) Q:ZN="" D ; FOR EACH MULTIPLE 233 . . N ZS S ZS="" 234 . . I $O(@ZARY@(ZI,ZN,ZS))'["." D ; END NODES HERE 235 . . . N NEWARY 236 . . . S NEWARY=$NA(@ZARY@(ZI,ZN)) 237 . . . D MINOR("NEWARY") ; INSERT THE END NODES 238 . . E F S ZS=$O(@ZARY@(ZI,ZN,ZS)) Q:ZS="" D ; FOR EACH STRING 239 . . . I ZS["." D ; INTERMEDIATE NODE FOUND 240 . . . . W !,"IM:",ZS 241 . . . W !,ZI,":",ZN,":",ZS_" : ",@ZARY@(ZI,ZN,ZS) 242 Q 243 ; 244 MINOR(ZINARY) ; DOES THE WORK FOR END NODES, HANDLES ATTRIBUTES 245 ; 246 N ZZI S ZZI="" 247 F S ZZI=$O(@ZINARY@(ZZI)) Q:ZZI="" D ; 248 . W !,"MINOR",ZZI,":",@ZINARY@(ZZI) 261 . . D STARTELE^MXMLDOM(ZI) ; ADD THE INTERMEDIATE TAG 262 . . S NEWARY=$NA(@ZARY@(ZI,ZN)) ; INDENT THE ARRAY 263 . . D MAJOR(NEWARY) ; RECURSE FOR INDENTED ARRAY 264 . . D ENDELE^MXMLDOM(ZI) ; END THE INTERMEDIATE TAG 249 265 Q 250 266 ; … … 268 284 . . . N ZZV ; PLACE TO STASH THE VALUE 269 285 . . . S ZZV=@ZZIN@(ZZI,ZZN,ZZS) ; VALUE 286 . . . W !,"VALUE:",ZZV 270 287 . . . N GK ; COUNTER 271 288 . . . F GK=1:1:$L(ZZS,".") D ; FOR EACH INTERMEDIATE NODE … … 292 309 Q 293 310 ; 294 POP(OSTR,ISTR) ; EXTRINSIC WHICH RETURNS TRUE IF ISTR IS EMPTY295 ; IF ISTR IS NOT EMPTY, LOOKS FOR "." AND "@" AND RETURNS296 ; xxx,1,yyyetc for xxx.yyyetc and xx@,1,yyy for xxx@yyyetc297 ; OSTR IS PASSED BY REFERENCE AND CONTAINS yyyetc298 I $L(ISTR)=0 Q 1 ; WE ARE DONE299 N ZG,ZN,ZR300 S ZN=1301 I ISTR["." D ;302 . S ZG=$P(ISTR,".",1)303 . S OSTR=$P(ISTR,".",2)304 . S ZR=ZG_","_ZN_","_OSTR305 Q ZR306 ;307 311 NEWDOM() ; extrinsic which creates a new DOM and returns the HANDLE 308 312 N CBK,SUCCESS,LEVEL,NODE,HANDLE … … 314 318 Q HANDLE 315 319 ; 316 317
Note:
See TracChangeset
for help on using the changeset viewer.