src/Tools/isac/xmlsrc/pbl-met-hierarchy.sml
branchisac-update-Isa09-2
changeset 38031 460c24a6a6ba
parent 38015 67ba02dffacc
child 38050 4c52ad406c20
equal deleted inserted replaced
38030:95d956108461 38031:460c24a6a6ba
     9 fun str2file (fnm:filename) (str:string) =
     9 fun str2file (fnm:filename) (str:string) =
    10     let val file = TextIO.openOut fnm
    10     let val file = TextIO.openOut fnm
    11     in (TextIO.output (file, str);
    11     in (TextIO.output (file, str);
    12 	TextIO.flushOut file;
    12 	TextIO.flushOut file;
    13 	TextIO.closeOut file) end;
    13 	TextIO.closeOut file) end;
    14 fun pos2filename [] = raise error "pos2filename called with []"
    14 fun pos2filename [] = error "pos2filename called with []"
    15   | pos2filename [i] = "_" ^ string_of_int i ^ ".xml"
    15   | pos2filename [i] = "_" ^ string_of_int i ^ ".xml"
    16   | pos2filename (i::is) = "_" ^ string_of_int i ^ pos2filename is;
    16   | pos2filename (i::is) = "_" ^ string_of_int i ^ pos2filename is;
    17 (* pos2filename [1,22,3];
    17 (* pos2filename [1,22,3];
    18 val it = "_1_22_3.xml" : string
    18 val it = "_1_22_3.xml" : string
    19 *)
    19 *)
    20 fun id2filename [] = raise error "id2filename called with []"
    20 fun id2filename [] = error "id2filename called with []"
    21   | id2filename [s] = s ^ ".xml"
    21   | id2filename [s] = s ^ ".xml"
    22   | id2filename (s::ss) = s ^ "_" ^ id2filename ss;
    22   | id2filename (s::ss) = s ^ "_" ^ id2filename ss;
    23 (* id2filename ["linear","univariate","equation"];
    23 (* id2filename ["linear","univariate","equation"];
    24 val it = "linear_univariate_equation.xml" : string
    24 val it = "linear_univariate_equation.xml" : string
    25 *)
    25 *)
    75 	       (indt i) ^ "</NODE>\n"
    75 	       (indt i) ^ "</NODE>\n"
    76 	    end
    76 	    end
    77 	and nds _ _ [] = ""
    77 	and nds _ _ [] = ""
    78 	  | nds i p (n::ns) = (nd i p n) ^ (nds i (lev_on p) ns);
    78 	  | nds i p (n::ns) = (nd i p n) ^ (nds i (lev_on p) ns);
    79     in nds j [0] h  : xml end;
    79     in nds j [0] h  : xml end;
    80 (* (tracing o hierarchy_pbl) (!ptyps);
    80 (* (writeln o hierarchy_pbl) (!ptyps);
    81    *)
    81    *)
    82 
    82 
    83 fun pbl_hierarchy2file (path:path) = 
    83 fun pbl_hierarchy2file (path:path) = 
    84     str2file (path ^ "pbl_hierarchy.xml") 
    84     str2file (path ^ "pbl_hierarchy.xml") 
    85 	     ("<NODE>\n" ^
    85 	     ("<NODE>\n" ^
   190     authors2xml i "COURSEDESIGNS" ["isac team 2006"] ^
   190     authors2xml i "COURSEDESIGNS" ["isac team 2006"] ^
   191     "</NODECONTENT>" : xml;
   191     "</NODECONTENT>" : xml;
   192 (* 
   192 (* 
   193 val pblID = ["linear","univariate","equation"];
   193 val pblID = ["linear","univariate","equation"];
   194 val pblID = ["degree_4","polynomial","univariate","equation"];
   194 val pblID = ["degree_4","polynomial","univariate","equation"];
   195 tracing (pbl2xml pblID (get_pbt pblID));
   195 writeln (pbl2xml pblID (get_pbt pblID));
   196 *)
   196 *)
   197 
   197 
   198 (*replace by 'fun calc2xml' as developed for thy in 0607*)
   198 (*replace by 'fun calc2xml' as developed for thy in 0607*)
   199 fun calc2xmlOLD j ((scr_op, (isa_op, _)):calc) =
   199 fun calc2xmlOLD j ((scr_op, (isa_op, _)):calc) =
   200     indt i ^ "<CALCULATE> (" ^ scr_op ^ ", (" ^ isa_op ^ ")) </CALCULATE>\n";
   200     indt i ^ "<CALCULATE> (" ^ scr_op ^ ", (" ^ isa_op ^ ")) </CALCULATE>\n";
   268     calcs2xmlOLD i calc ^
   268     calcs2xmlOLD i calc ^
   269     authors2xml i "MATHAUTHORS" mathauthors ^
   269     authors2xml i "MATHAUTHORS" mathauthors ^
   270     authors2xml i "COURSEDESIGNS" ["isac team 2006"] ^
   270     authors2xml i "COURSEDESIGNS" ["isac team 2006"] ^
   271     "</NODECONTENT>" : xml;
   271     "</NODECONTENT>" : xml;
   272 
   272 
   273 (* tracing (met2xml ["Test", "solve_linear"]
   273 (* writeln (met2xml ["Test", "solve_linear"]
   274 		    (get_met ["Test", "solve_linear"]));
   274 		    (get_met ["Test", "solve_linear"]));
   275    *)
   275    *)
   276 
   276 
   277 (**. write pbls from hierarchy to files.**)
   277 (**. write pbls from hierarchy to files.**)
   278 
   278 
   279 (*.write the files using an int-key (pos') as filename.*)
   279 (*.write the files using an int-key (pos') as filename.*)
   280 fun pbl2file (path:path) (pos:pos) (id:metID) (pbl as {guh,...}) =
   280 fun pbl2file (path:path) (pos:pos) (id:metID) (pbl as {guh,...}) =
   281     (tracing ("### pbl2file: id = " ^ strs2str id);
   281     (writeln ("### pbl2file: id = " ^ strs2str id);
   282     ((str2file (path ^ pos2filename pos)) o (pbl2xml id)) pbl
   282     ((str2file (path ^ pos2filename pos)) o (pbl2xml id)) pbl
   283     );
   283     );
   284 
   284 
   285 (*.write the files using the guh as filename.*)
   285 (*.write the files using the guh as filename.*)
   286 (*    *)
   286 (*    *)
   287 fun pbl2file (path:path) (pos:pos) (id:metID) (pbl as {guh,...}) =
   287 fun pbl2file (path:path) (pos:pos) (id:metID) (pbl as {guh,...}) =
   288     (tracing ("### pbl2file: id = " ^ strs2str id ^ ", pos = " ^ pos2str pos);
   288     (writeln ("### pbl2file: id = " ^ strs2str id ^ ", pos = " ^ pos2str pos);
   289      ((str2file (path ^ guh2filename guh)) o (pbl2xml id)) pbl
   289      ((str2file (path ^ guh2filename guh)) o (pbl2xml id)) pbl
   290      );
   290      );
   291     
   291     
   292 (**. write mets from hierarchy to files.**)
   292 (**. write mets from hierarchy to files.**)
   293 
   293 
   294 (*.write the files using an int-key (pos') as filename.*)
   294 (*.write the files using an int-key (pos') as filename.*)
   295 fun met2file (path:path) (pos:pos) (id:metID) met =
   295 fun met2file (path:path) (pos:pos) (id:metID) met =
   296     (tracing ("### met2file: id = " ^ strs2str id);
   296     (writeln ("### met2file: id = " ^ strs2str id);
   297      ((str2file (path ^ "met" ^ pos2filename pos)) o (met2xml id)) met);
   297      ((str2file (path ^ "met" ^ pos2filename pos)) o (met2xml id)) met);
   298 
   298 
   299 (*.write the files using the guh as filename.*)
   299 (*.write the files using the guh as filename.*)
   300 fun met2file (path:path) (pos:pos) (id:metID) (met as {guh,...}) =
   300 fun met2file (path:path) (pos:pos) (id:metID) (met as {guh,...}) =
   301     (tracing ("### met2file: id = " ^ strs2str id);
   301     (writeln ("### met2file: id = " ^ strs2str id);
   302      ((str2file (path ^ guh2filename guh)) o (met2xml id)) met);
   302      ((str2file (path ^ guh2filename guh)) o (met2xml id)) met);
   303 
   303 
   304 
   304 
   305 (*.scan the mtree Ptyp and and print the nodes using wfn.*)
   305 (*.scan the mtree Ptyp and and print the nodes using wfn.*)
   306 fun node (pa:path) ids po wfn (Ptyp (id,[n],ns)) = 
   306 fun node (pa:path) ids po wfn (Ptyp (id,[n],ns)) =