source: ccr/trunk/p/C0CMXP.m@ 644

Last change on this file since 644 was 640, checked in by George Lilly, 15 years ago

xml file support

File size: 3.1 KB
RevLine 
[630]1C0CMXP ; GPL - MXML based XPath utilities;12/04/09 17:05
2 ;;0.1;C0C;nopatch;noreleasedate
3 ;Copyright 2009 George Lilly. Licensed under the terms of the GNU
4 ;General Public License See attached copy of the License.
5 ;
6 ;This program is free software; you can redistribute it and/or modify
7 ;it under the terms of the GNU General Public License as published by
8 ;the Free Software Foundation; either version 2 of the License, or
9 ;(at your option) any later version.
10 ;
11 ;This program is distributed in the hope that it will be useful,
12 ;but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;GNU General Public License for more details.
15 ;
16 ;You should have received a copy of the GNU General Public License along
17 ;with this program; if not, write to the Free Software Foundation, Inc.,
18 ;51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 ;
20 Q
21 ;
[640]22INITXPF(ARY) ;INITIAL XML/XPATH FILE ARRAY
23 ;
24 S @ARY@("XML FILE NUMBER")=178.101
25 S @ARY@("XML SOURCE FIELD")=2.1
26 S @ARY@("XML TEMPLATE FIELD")=3
27 S @ARY@("XPATH BINDING SUBFILE")=178.1014
28 Q
29 ;
30SETXPF(ARY) ; SET FILE AND FIELD VARIABLES FROM XPF ARRAY
31 ;
32 S C0CXPF=@ARY@("XML FILE NUMBER")
33 S C0CXFLD=@ARY@("XML SOURCE FIELD")
34 S C0CXTFLD=@ARY@("XML TEMPLATE FIELD")
35 S C0CXPBF=@ARY@("XPATH BINDING SUBFILE")
36 Q
37 ;
38ADDXP(INARY,TID,FARY) ;ADD XPATH .01 FIELD TO BINDING SUBFILE OF TEMPLATE TID
39 I '$D(FARY) D ;
40 . S FARY="FARY" ; FILE ARRAY
41 . D INITXPF("FARY") ;IF FILE ARRAY NOT PASSED, INITIALIZE
42 D SETXPF(FARY) ;SET FILE VARIABLES
43 N C0CA,C0CB
44 S C0CA="" S C0CB=0
45 F S C0CA=$O(@INARY@(C0CA)) Q:C0CA="" D ; FOR EACH XPATH
46 . S C0CB=C0CB+1 ; COUNT OF XPATHS
47 . S C0CFDA(C0CXPBF,"?+"_C0CB_","_TID_",",.01)=C0CA
48 . D UPDIE ; CREATE THE BINDING SUBFILE FOR THIS XPATH
49 Q
50 ;
51ADDXML(INXML,TEMPID,FARY) ;ADD XML TO A TEMPLATE ID TEMPID
52 ; INXML IS PASSED BY NAME
53 I '$D(FARY) D ;
54 . S FARY="FARY" ; FILE ARRAY
55 . D INITXPF("FARY") ;IF FILE ARRAY NOT PASSED, INITIALIZE
56 D SETXPF(FARY) ;SET FILE VARIABLES
57 D WP^DIE(C0CXPF,TEMPID_",",C0CXFLD,,INXML)
58 Q
59 ;
60ADDTEMP(INXML,TEMPID,FARY) ;ADD XML TEMPLATE TO TEMPLATE RECORD TEMPID FIELD 3
61 ;
62 I '$D(FARY) D ;
63 . S FARY="FARY" ; FILE ARRAY
64 . D INITXPF("FARY") ;IF FILE ARRAY NOT PASSED, INITIALIZE
65 D SETXPF(FARY) ;SET FILE VARIABLES
66 D WP^DIE(C0CXPF,TEMPID_",",C0CXTFLD,,INXML)
67 Q
68 ;
69GETXML(OUTXML,TEMPID,FARY) ;GET THE XML FROM TEMPLATE TEMPID
70 ;
71 I '$D(FARY) D ;
72 . S FARY="FARY" ; FILE ARRAY
73 . D INITXPF("FARY") ;IF FILE ARRAY NOT PASSED, INITIALIZE
74 D SETXPF(FARY) ;SET FILE VARIABLES
75 I $$GET1^DIQ(C0CXPF,TEMPID_",",C0CXFLD,,OUTXML)'=OUTXML D Q ;
76 . W "ERROR RETRIEVING TEMPLATE",!
77 Q
78 ;
[630]79MKTPLATE(INXML,OUTT) ;MAKE A TEMPLATE FROM INXML, RETURNED IN OUTT
80 ; BOTH PASSED BY NAME
81 ;
[640]82 S C0CDOCID=$$PARSE^C0CMXML(INXML,"C0CMKT")
[630]83 S C0CDOM=$NA(^TMP("MXMLDOM",$J,C0CDOCID))
84 N ZI S ZI=""
85 F S ZI=$O(@C0CDOM@(ZI)) Q:ZI="" D ; FOR EACH NODE IN THE DOM
[640]86 . W !,ZI,$$TAG^C0CMXML(ZI)
[630]87 Q
88 ;
89UPDIE ; INTERNAL ROUTINE TO CALL UPDATE^DIE AND CHECK FOR ERRORS
90 K ZERR
91 D CLEAN^DILF
92 D UPDATE^DIE("","C0CFDA","","ZERR")
93 I $D(ZERR) D ;
94 . W "ERROR",!
95 . ZWR ZERR
96 . B
97 K C0CFDA
98 Q
99 ;
Note: See TracBrowser for help on using the repository browser.