neuper@37871
|
1 |
(* export problem-data and method-data to xml
|
neuper@37871
|
2 |
author: Walther Neuper
|
neuper@37871
|
3 |
(c) isac-team
|
neuper@37871
|
4 |
|
neuper@37871
|
5 |
use"xmlsrc/pbl-met-hierarchy.sml";
|
neuper@37871
|
6 |
use"pbl-met-hierarchy.sml";
|
neuper@37871
|
7 |
*)
|
neuper@37871
|
8 |
|
neuper@37871
|
9 |
fun str2file (fnm:filename) (str:string) =
|
neuper@37871
|
10 |
let val file = TextIO.openOut fnm
|
neuper@37871
|
11 |
in (TextIO.output (file, str);
|
neuper@37871
|
12 |
TextIO.flushOut file;
|
neuper@37871
|
13 |
TextIO.closeOut file) end;
|
neuper@37871
|
14 |
fun pos2filename [] = raise error "pos2filename called with []"
|
neuper@37871
|
15 |
| pos2filename [i] = "_" ^ string_of_int i ^ ".xml"
|
neuper@37871
|
16 |
| pos2filename (i::is) = "_" ^ string_of_int i ^ pos2filename is;
|
neuper@37871
|
17 |
(* pos2filename [1,22,3];
|
neuper@37871
|
18 |
val it = "_1_22_3.xml" : string
|
neuper@37871
|
19 |
*)
|
neuper@37871
|
20 |
fun id2filename [] = raise error "id2filename called with []"
|
neuper@37871
|
21 |
| id2filename [s] = s ^ ".xml"
|
neuper@37871
|
22 |
| id2filename (s::ss) = s ^ "_" ^ id2filename ss;
|
neuper@37871
|
23 |
(* id2filename ["linear","univariate","equation"];
|
neuper@37871
|
24 |
val it = "linear_univariate_equation.xml" : string
|
neuper@37871
|
25 |
*)
|
neuper@37871
|
26 |
|
neuper@37871
|
27 |
|
neuper@37871
|
28 |
|
neuper@37871
|
29 |
(*ad DTD: a NODE contains an ID and zero or more NODEs*)
|
neuper@37871
|
30 |
(*old version with pos2filename*)
|
neuper@37871
|
31 |
fun hierarchy pm(*"pbl" | "met"*) h =
|
neuper@37871
|
32 |
let val j = indentation
|
neuper@37871
|
33 |
fun nd i p (Ptyp (id,_,ns)) =
|
neuper@37871
|
34 |
let val p' = lev_on p
|
neuper@37871
|
35 |
in (indt i) ^ "<NODE>\n" ^
|
neuper@37871
|
36 |
(indt (i+j)) ^ "<ID> " ^ id ^ " </ID>\n" ^
|
neuper@37871
|
37 |
(indt (i+j)) ^ "<NO> " (*on this level*) ^
|
neuper@37871
|
38 |
(string_of_int o last_elem) p' ^ " </NO>\n" ^
|
neuper@37871
|
39 |
(indt (i+j)) ^ "<CONTENTREF> " ^ pm ^ pos2filename p' ^
|
neuper@37871
|
40 |
" </CONTENTREF>\n" ^
|
neuper@37871
|
41 |
(nds (i+j) (lev_dn p') ns) ^
|
neuper@37871
|
42 |
(indt i) ^ "</NODE>\n"
|
neuper@37871
|
43 |
end
|
neuper@37871
|
44 |
and nds _ _ [] = ""
|
neuper@37871
|
45 |
| nds i p (n::ns) = (nd i p n) ^ (nds i (lev_on p) ns);
|
neuper@37871
|
46 |
in nds j [0] h end;
|
neuper@37871
|
47 |
(*.create a hierarchy with references to the guh's.*)
|
neuper@37871
|
48 |
fun hierarchy_pbl h =
|
neuper@37871
|
49 |
let val j = indentation
|
neuper@37871
|
50 |
fun nd i p (Ptyp (id,[n as {guh,...} : pbt],ns)) =
|
neuper@37871
|
51 |
let val p' = lev_on p
|
neuper@37871
|
52 |
in (indt i) ^ "<NODE>\n" ^
|
neuper@37871
|
53 |
(indt (i+j)) ^ "<ID> " ^ id ^ " </ID>\n" ^
|
neuper@37871
|
54 |
(indt (i+j)) ^ "<NO> " (*on this level*) ^
|
neuper@37871
|
55 |
(string_of_int o last_elem) p' ^ " </NO>\n" ^
|
neuper@37871
|
56 |
(indt (i+j)) ^ "<CONTENTREF> " ^ guh ^
|
neuper@37871
|
57 |
" </CONTENTREF>\n" ^
|
neuper@37871
|
58 |
(nds (i+j) (lev_dn p') ns) ^
|
neuper@37871
|
59 |
(indt i) ^ "</NODE>\n"
|
neuper@37871
|
60 |
end
|
neuper@37871
|
61 |
and nds _ _ [] = ""
|
neuper@37871
|
62 |
| nds i p (n::ns) = (nd i p n) ^ (nds i (lev_on p) ns);
|
neuper@37871
|
63 |
in nds j [0] h : xml end;
|
neuper@37871
|
64 |
fun hierarchy_met h =
|
neuper@37871
|
65 |
let val j = indentation
|
neuper@37871
|
66 |
fun nd i p (Ptyp (id,[n as {guh,...} : met],ns)) =
|
neuper@37871
|
67 |
let val p' = lev_on p
|
neuper@37871
|
68 |
in (indt i) ^ "<NODE>\n" ^
|
neuper@37871
|
69 |
(indt (i+j)) ^ "<ID> " ^ id ^ " </ID>\n" ^
|
neuper@37871
|
70 |
(indt (i+j)) ^ "<NO> " (*on this level*) ^
|
neuper@37871
|
71 |
(string_of_int o last_elem) p' ^ " </NO>\n" ^
|
neuper@37871
|
72 |
(indt (i+j)) ^ "<CONTENTREF> " ^ guh ^
|
neuper@37871
|
73 |
" </CONTENTREF>\n" ^
|
neuper@37871
|
74 |
(nds (i+j) (lev_dn p') ns) ^
|
neuper@37871
|
75 |
(indt i) ^ "</NODE>\n"
|
neuper@37871
|
76 |
end
|
neuper@37871
|
77 |
and nds _ _ [] = ""
|
neuper@37871
|
78 |
| nds i p (n::ns) = (nd i p n) ^ (nds i (lev_on p) ns);
|
neuper@37871
|
79 |
in nds j [0] h : xml end;
|
neuper@37871
|
80 |
(* (writeln o hierarchy_pbl) (!ptyps);
|
neuper@37871
|
81 |
*)
|
neuper@37871
|
82 |
|
neuper@37871
|
83 |
fun pbl_hierarchy2file (path:path) =
|
neuper@37871
|
84 |
str2file (path ^ "pbl_hierarchy.xml")
|
neuper@37871
|
85 |
("<NODE>\n" ^
|
neuper@37871
|
86 |
" <ID> problem hierarchy </ID>\n" ^
|
neuper@37871
|
87 |
" <NO> 1 </NO>\n" ^
|
neuper@37871
|
88 |
" <CONTENTREF> pbl_ROOT </CONTENTREF>\n" ^
|
neuper@37871
|
89 |
(hierarchy_pbl (!ptyps)) ^
|
neuper@37871
|
90 |
"</NODE>");
|
neuper@37871
|
91 |
|
neuper@37871
|
92 |
fun met_hierarchy2file (path:path) =
|
neuper@37871
|
93 |
str2file (path ^ "met_hierarchy.xml")
|
neuper@37871
|
94 |
("<NODE>\n" ^
|
neuper@37871
|
95 |
" <ID> method hierarchy </ID>\n" ^
|
neuper@37871
|
96 |
" <NO> 1 </NO>\n" ^
|
neuper@37871
|
97 |
" <CONTENTREF> met_ROOT </CONTENTREF>\n" ^
|
neuper@37871
|
98 |
(hierarchy_met (!mets)) ^
|
neuper@37871
|
99 |
"</NODE>");
|
neuper@37871
|
100 |
|
neuper@37871
|
101 |
|
neuper@37871
|
102 |
|
neuper@37871
|
103 |
(**.create the xml-files for the pbls, mets from the hierarchy.**)
|
neuper@37871
|
104 |
|
neuper@37871
|
105 |
val i = indentation;
|
neuper@37871
|
106 |
|
neuper@37871
|
107 |
fun pbl2term thy (pblRD:pblRD) =
|
neuper@37871
|
108 |
str2term ("Problem (" ^
|
neuper@37871
|
109 |
(get_thy o theory2domID) thy ^ "_, " ^
|
neuper@37871
|
110 |
(strs2str' o rev) pblRD ^ ")");
|
neuper@37871
|
111 |
(* term2str (pbl2term Isac.thy ["equations","univariate","normalize"]);
|
neuper@37871
|
112 |
val it = "Problem (Isac, [normalize, univariate, equations])" : string
|
neuper@37871
|
113 |
*)
|
neuper@37871
|
114 |
|
neuper@37871
|
115 |
|
neuper@37871
|
116 |
(*.format a problem in xml for presentation on the problem browser;
|
neuper@37871
|
117 |
new version with <KESTOREREF>s -- not used because linking
|
neuper@37871
|
118 |
requires elements (rls, calc, ...) to be reorganized.*)
|
neuper@37871
|
119 |
(*######## ATTENTION: THIS IS not THE ACTUAL VERSION ################*)
|
neuper@37871
|
120 |
fun pbl2xml (id:(*pblRD*)pblID) ({guh,mathauthors,init,cas,met,ppc,prls,
|
neuper@37871
|
121 |
thy,where_}:pbt) =
|
neuper@37871
|
122 |
let val thy' = theory2theory' thy
|
neuper@37871
|
123 |
val prls' = (#id o rep_rls) prls
|
neuper@37871
|
124 |
in "<NODECONTENT>\n" ^
|
neuper@37871
|
125 |
indt i ^ "<GUH> " ^ guh ^ " </GUH>\n" ^
|
neuper@37871
|
126 |
(((id2xml i)(* o rev*)) id) ^
|
neuper@37871
|
127 |
indt i ^ "<META> </META>\n" ^
|
neuper@37871
|
128 |
(*--------------- begin display ------------------------------*)
|
neuper@37871
|
129 |
indt i ^ "<HEADLINE>\n" ^
|
neuper@37871
|
130 |
(case cas of None => term2xml i (pbl2term thy id)
|
neuper@37871
|
131 |
| Some t => term2xml i t) ^ "\n" ^
|
neuper@37871
|
132 |
indt i ^ "</HEADLINE>\n" ^
|
neuper@37871
|
133 |
(*--------------- hline --------------------------------------*)
|
neuper@37871
|
134 |
pattern2xml i ppc where_ ^
|
neuper@37871
|
135 |
(*--------------- hline --------------------------------------*)
|
neuper@37871
|
136 |
indt i ^ "<EXPLANATIONS> </EXPLANATIONS>\n"
|
neuper@37871
|
137 |
(*--------------- end display --------------------------------*)
|
neuper@37871
|
138 |
^
|
neuper@37871
|
139 |
indt i ^ "<THEORY>\n" ^
|
neuper@37871
|
140 |
theref2xml (i+i) thy' "Theorems" "" ^
|
neuper@37871
|
141 |
indt i ^ "</THEORY>\n" ^
|
neuper@37871
|
142 |
(case met of [] => (indt i) ^ "<METHODS> </METHODS>\n"
|
neuper@37871
|
143 |
| _ => (indt i) ^ "<METHODS>\n" ^
|
neuper@37871
|
144 |
foldl op^ ("", map (keref2xml (i+i) Met_) met) ^
|
neuper@37871
|
145 |
(indt i) ^ "</METHODS>\n") ^
|
neuper@37871
|
146 |
indt i ^ "<EVALPRECOND>\n" ^
|
neuper@37871
|
147 |
theref2xml (i+i) (snd (thy_containing_rls thy' prls')) "Rulesets" prls'^
|
neuper@37871
|
148 |
indt i ^ "</EVALPRECOND>\n" ^
|
neuper@37871
|
149 |
authors2xml i "MATHAUTHORS" mathauthors ^
|
neuper@37871
|
150 |
authors2xml i "COURSEDESIGNS" ["isac team 2006"] ^
|
neuper@37871
|
151 |
"</NODECONTENT>" : xml
|
neuper@37871
|
152 |
end;
|
neuper@37871
|
153 |
|
neuper@37871
|
154 |
(*.format a problem in xml for presentation on the problem browser;
|
neuper@37871
|
155 |
old version with 'dead' strings for rls, calc, ....*)
|
neuper@37871
|
156 |
(*
|
neuper@37871
|
157 |
val pblID = ["linear","univariate","equation"];
|
neuper@37871
|
158 |
val pblID = ["degree_4","polynomial","univariate","equation"];
|
neuper@37871
|
159 |
val pblID = rev ["tool","find_values"];
|
neuper@37871
|
160 |
val (id, {guh,mathauthors,init,cas,met,ppc,prls,thy,where_}:pbt) =
|
neuper@37871
|
161 |
(pblID, get_pbt pblID);
|
neuper@37871
|
162 |
*)
|
neuper@37871
|
163 |
fun pbl2xml (id:(*pblRD*)pblID) ({guh,mathauthors,init,cas,met,ppc,prls,
|
neuper@37871
|
164 |
thy,where_}:pbt) =
|
neuper@37871
|
165 |
"<NODECONTENT>\n" ^
|
neuper@37871
|
166 |
indt i ^ "<GUH> " ^ guh ^ " </GUH>\n" ^
|
neuper@37871
|
167 |
(((id2xml i)(* o rev*)) id) ^
|
neuper@37871
|
168 |
indt i ^ "<META> </META>\n" ^
|
neuper@37871
|
169 |
(*--------------- begin display ------------------------------*)
|
neuper@37871
|
170 |
indt i ^ "<HEADLINE>\n" ^
|
neuper@37871
|
171 |
(case cas of None => term2xml i (pbl2term thy id)
|
neuper@37871
|
172 |
| Some t => term2xml i t) ^ "\n" ^
|
neuper@37871
|
173 |
indt i ^ "</HEADLINE>\n" ^
|
neuper@37871
|
174 |
(*--------------- hline --------------------------------------*)
|
neuper@37871
|
175 |
pattern2xml i ppc where_ ^
|
neuper@37871
|
176 |
(*--------------- hline --------------------------------------*)
|
neuper@37871
|
177 |
indt i ^ "<EXPLANATIONS> </EXPLANATIONS>\n"
|
neuper@37871
|
178 |
(*--------------- end display --------------------------------*)
|
neuper@37871
|
179 |
^
|
neuper@37871
|
180 |
indt i ^ "<THEORY>\n" ^
|
neuper@37871
|
181 |
theref2xml (i+i) (theory2theory' thy) "Theorems" "" ^
|
neuper@37871
|
182 |
indt i ^ "</THEORY>\n" ^
|
neuper@37871
|
183 |
(case met of [] => (indt i) ^ "<METHODS> </METHODS>\n"
|
neuper@37871
|
184 |
| _ => (indt i) ^ "<METHODS>\n" ^
|
neuper@37871
|
185 |
foldl op^ ("", map (keref2xml (i+i) Met_) met) ^
|
neuper@37871
|
186 |
(indt i) ^ "</METHODS>\n") ^
|
neuper@37871
|
187 |
indt i ^ "<EVALPRECOND> " ^ (#id o rep_rls)
|
neuper@37871
|
188 |
prls ^ " </EVALPRECOND>\n" ^
|
neuper@37871
|
189 |
authors2xml i "MATHAUTHORS" mathauthors ^
|
neuper@37871
|
190 |
authors2xml i "COURSEDESIGNS" ["isac team 2006"] ^
|
neuper@37871
|
191 |
"</NODECONTENT>" : xml;
|
neuper@37871
|
192 |
(*
|
neuper@37871
|
193 |
val pblID = ["linear","univariate","equation"];
|
neuper@37871
|
194 |
val pblID = ["degree_4","polynomial","univariate","equation"];
|
neuper@37871
|
195 |
writeln (pbl2xml pblID (get_pbt pblID));
|
neuper@37871
|
196 |
*)
|
neuper@37871
|
197 |
|
neuper@37871
|
198 |
(*replace by 'fun calc2xml' as developed for thy in 0607*)
|
neuper@37871
|
199 |
fun calc2xmlOLD j ((scr_op, (isa_op, _)):calc) =
|
neuper@37871
|
200 |
indt i ^ "<CALCULATE> (" ^ scr_op ^ ", (" ^ isa_op ^ ")) </CALCULATE>\n";
|
neuper@37871
|
201 |
fun calcs2xmlOLD j [] = ("":xml) (*TODO replace with 'strs2xml'*)
|
neuper@37871
|
202 |
| calcs2xmlOLD j (r::rs) = calc2xmlOLD j r ^ calcs2xmlOLD j rs;
|
neuper@37871
|
203 |
|
neuper@37871
|
204 |
(* val (id, {guh,mathauthors,init,ppc,pre,scr,calc,
|
neuper@37871
|
205 |
crls,erls,nrls,prls,srls,rew_ord'}) =
|
neuper@37871
|
206 |
(["Test", "solve_linear"],
|
neuper@37871
|
207 |
get_met ["Test", "solve_linear"]);
|
neuper@37871
|
208 |
*)
|
neuper@37871
|
209 |
|
neuper@37871
|
210 |
(*.format a method in xml for presentation on the method browser;
|
neuper@37871
|
211 |
new version with <KESTOREREF>s -- not used because linking
|
neuper@37871
|
212 |
requires elements (rls, calc, ...) to be reorganized.*)
|
neuper@37871
|
213 |
(*######## ATTENTION: THIS IS not THE ACTUAL VERSION ################*)
|
neuper@37871
|
214 |
fun met2xml (id:metID) ({guh,mathauthors,init,ppc,pre,scr,calc,
|
neuper@37871
|
215 |
crls,erls,nrls,prls,srls,rew_ord'}:met) =
|
neuper@37871
|
216 |
let val thy' = "Isac.thy" (*FIXME.WN0607 get thy from met ?!?*)
|
neuper@37871
|
217 |
val crls' = (#id o rep_rls) crls
|
neuper@37871
|
218 |
val erls' = (#id o rep_rls) erls
|
neuper@37871
|
219 |
val nrls' = (#id o rep_rls) nrls
|
neuper@37871
|
220 |
val prls' = (#id o rep_rls) prls
|
neuper@37871
|
221 |
val srls' = (#id o rep_rls) srls
|
neuper@37871
|
222 |
in "<NODECONTENT>\n" ^
|
neuper@37871
|
223 |
indt i ^ "<GUH> " ^ guh ^ " </GUH>\n" ^
|
neuper@37871
|
224 |
id2xml i id ^
|
neuper@37871
|
225 |
indt i ^ "<META> </META>\n" ^
|
neuper@37871
|
226 |
scr2xml i scr ^
|
neuper@37871
|
227 |
pattern2xml i ppc pre ^
|
neuper@37871
|
228 |
indt i ^ "<EXPLANATIONS> </EXPLANATIONS>\n" ^
|
neuper@37871
|
229 |
indt i ^ "<EVALPRECOND>\n" ^
|
neuper@37871
|
230 |
theref2xml (i+i) (snd (thy_containing_rls thy' prls')) "Rulesets" prls'^
|
neuper@37871
|
231 |
indt i ^ "</EVALPRECOND>\n" ^
|
neuper@37871
|
232 |
indt i ^ "<EVALCOND>\n" ^
|
neuper@37871
|
233 |
theref2xml (i+i) (snd (thy_containing_rls thy' erls')) "Rulesets" erls'^
|
neuper@37871
|
234 |
indt i ^ "</EVALCOND>\n" ^
|
neuper@37871
|
235 |
indt i ^ "<EVALLISTEXPR>\n"^
|
neuper@37871
|
236 |
theref2xml (i+i) (snd (thy_containing_rls thy' srls')) "Rulesets" srls'^
|
neuper@37871
|
237 |
indt i ^ "</EVALLISTEXPR>\n" ^
|
neuper@37871
|
238 |
indt i ^ "<CHECKELEMENTWISE>\n" ^
|
neuper@37871
|
239 |
theref2xml (i+i) (snd (thy_containing_rls thy' crls')) "Rulesets" crls'^
|
neuper@37871
|
240 |
indt i ^ "</CHECKELEMENTWISE>\n" ^
|
neuper@37871
|
241 |
indt i ^ "<NORMALFORM>\n" ^
|
neuper@37871
|
242 |
theref2xml (i+i) (snd (thy_containing_rls thy' nrls')) "Rulesets" nrls'^
|
neuper@37871
|
243 |
indt i ^ "</NORMALFORM>\n" ^
|
neuper@37871
|
244 |
indt i ^ "<REWORDER> " ^ rew_ord' ^ " </REWORDER>\n" ^
|
neuper@37871
|
245 |
calcs2xmlOLD i calc ^
|
neuper@37871
|
246 |
authors2xml i "MATHAUTHORS" mathauthors ^
|
neuper@37871
|
247 |
authors2xml i "COURSEDESIGNS" ["isac team 2006"] ^
|
neuper@37871
|
248 |
"</NODECONTENT>" : xml
|
neuper@37871
|
249 |
end;
|
neuper@37871
|
250 |
(*.format a method in xml for presentation on the method browser;
|
neuper@37871
|
251 |
old version with 'dead' strings for rls, calc, ....*)
|
neuper@37871
|
252 |
fun met2xml (id:metID) ({guh,mathauthors,init,ppc,pre,scr,calc,
|
neuper@37871
|
253 |
crls,erls,nrls,prls,srls,rew_ord'}:met) =
|
neuper@37871
|
254 |
"<NODECONTENT>\n" ^
|
neuper@37871
|
255 |
indt i ^ "<GUH> " ^ guh ^ " </GUH>\n" ^
|
neuper@37871
|
256 |
id2xml i id ^
|
neuper@37871
|
257 |
indt i ^ "<META> </META>\n" ^
|
neuper@37871
|
258 |
scr2xml i scr ^
|
neuper@37871
|
259 |
pattern2xml i ppc pre ^
|
neuper@37871
|
260 |
indt i ^ "<EXPLANATIONS> </EXPLANATIONS>\n" ^
|
neuper@37871
|
261 |
indt i ^ "<EVALPRECOND> " ^ (#id o rep_rls) prls ^ " </EVALPRECOND>\n" ^
|
neuper@37871
|
262 |
indt i ^ "<EVALCOND> " ^ (#id o rep_rls) erls ^ " </EVALCOND>\n" ^
|
neuper@37871
|
263 |
indt i ^ "<EVALLISTEXPR> "^ (#id o rep_rls) srls ^ " </EVALLISTEXPR>\n" ^
|
neuper@37871
|
264 |
indt i ^ "<CHECKELEMENTWISE> " ^ (#id o rep_rls)
|
neuper@37871
|
265 |
crls ^ " </CHECKELEMENTWISE>\n" ^
|
neuper@37871
|
266 |
indt i ^ "<NORMALFORM> " ^ (#id o rep_rls) nrls ^ " </NORMALFORM>\n" ^
|
neuper@37871
|
267 |
indt i ^ "<REWORDER> " ^ rew_ord' ^ " </REWORDER>\n" ^
|
neuper@37871
|
268 |
calcs2xmlOLD i calc ^
|
neuper@37871
|
269 |
authors2xml i "MATHAUTHORS" mathauthors ^
|
neuper@37871
|
270 |
authors2xml i "COURSEDESIGNS" ["isac team 2006"] ^
|
neuper@37871
|
271 |
"</NODECONTENT>" : xml;
|
neuper@37871
|
272 |
|
neuper@37871
|
273 |
(* writeln (met2xml ["Test", "solve_linear"]
|
neuper@37871
|
274 |
(get_met ["Test", "solve_linear"]));
|
neuper@37871
|
275 |
*)
|
neuper@37871
|
276 |
|
neuper@37871
|
277 |
(**. write pbls from hierarchy to files.**)
|
neuper@37871
|
278 |
|
neuper@37871
|
279 |
(*.write the files using an int-key (pos') as filename.*)
|
neuper@37871
|
280 |
fun pbl2file (path:path) (pos:pos) (id:metID) (pbl as {guh,...}) =
|
neuper@37871
|
281 |
(writeln ("### pbl2file: id = " ^ strs2str id);
|
neuper@37871
|
282 |
((str2file (path ^ pos2filename pos)) o (pbl2xml id)) pbl
|
neuper@37871
|
283 |
);
|
neuper@37871
|
284 |
|
neuper@37871
|
285 |
(*.write the files using the guh as filename.*)
|
neuper@37871
|
286 |
(* *)
|
neuper@37871
|
287 |
fun pbl2file (path:path) (pos:pos) (id:metID) (pbl as {guh,...}) =
|
neuper@37871
|
288 |
(writeln ("### pbl2file: id = " ^ strs2str id ^ ", pos = " ^ pos2str pos);
|
neuper@37871
|
289 |
((str2file (path ^ guh2filename guh)) o (pbl2xml id)) pbl
|
neuper@37871
|
290 |
);
|
neuper@37871
|
291 |
|
neuper@37871
|
292 |
(**. write mets from hierarchy to files.**)
|
neuper@37871
|
293 |
|
neuper@37871
|
294 |
(*.write the files using an int-key (pos') as filename.*)
|
neuper@37871
|
295 |
fun met2file (path:path) (pos:pos) (id:metID) met =
|
neuper@37871
|
296 |
(writeln ("### met2file: id = " ^ strs2str id);
|
neuper@37871
|
297 |
((str2file (path ^ "met" ^ pos2filename pos)) o (met2xml id)) met);
|
neuper@37871
|
298 |
|
neuper@37871
|
299 |
(*.write the files using the guh as filename.*)
|
neuper@37871
|
300 |
fun met2file (path:path) (pos:pos) (id:metID) (met as {guh,...}) =
|
neuper@37871
|
301 |
(writeln ("### met2file: id = " ^ strs2str id);
|
neuper@37871
|
302 |
((str2file (path ^ guh2filename guh)) o (met2xml id)) met);
|
neuper@37871
|
303 |
|
neuper@37871
|
304 |
|
neuper@37871
|
305 |
(*.scan the mtree Ptyp and and print the nodes using wfn.*)
|
neuper@37871
|
306 |
fun node (pa:path) ids po wfn (Ptyp (id,[n],ns)) =
|
neuper@37871
|
307 |
let val po' = lev_on po
|
neuper@37871
|
308 |
in wfn pa po' (ids@[id]) n;
|
neuper@37871
|
309 |
nodes pa (ids@[id]) ((lev_dn po'):pos) wfn ns end
|
neuper@37871
|
310 |
and nodes _ _ _ _ [] = ()
|
neuper@37871
|
311 |
| nodes pa ids po wfn (n::ns) = (node pa ids po wfn n;
|
neuper@37871
|
312 |
nodes pa ids (lev_on po) wfn ns);
|
neuper@37871
|
313 |
|
neuper@37871
|
314 |
|
neuper@37871
|
315 |
fun pbls2file (p:path) = nodes p [] [0] pbl2file (!ptyps);
|
neuper@37871
|
316 |
fun mets2file (p:path) = nodes p [] [0] met2file (!mets);
|
neuper@37871
|
317 |
(*
|
neuper@37871
|
318 |
val path = "/home/neuper/proto2/isac/xmldata/";
|
neuper@37871
|
319 |
val path = "/home/neuper/tmp/";
|
neuper@37871
|
320 |
|
neuper@37871
|
321 |
pbl_hierarchy2file (path ^ "pbl/");
|
neuper@37871
|
322 |
pbls2file (path ^ "pbl/");
|
neuper@37871
|
323 |
|
neuper@37871
|
324 |
met_hierarchy2file (path ^ "met/");
|
neuper@37871
|
325 |
mets2file (path ^ "met/");
|
neuper@37871
|
326 |
|
neuper@37871
|
327 |
thy_hierarchy2file (path ^ "thy/");
|
neuper@37871
|
328 |
thes2file (path ^ "thy/");
|
neuper@37871
|
329 |
*) |