13 let myself = F.basename (Sys.argv.(0))
15 let msg = P.sprintf "This file was generated by %s, do not edit" myself
18 let str = S.make 4 'n' in
19 if cell.M.cb.T.n then str.[0] <- 's';
20 if cell.M.cb.T.e then str.[1] <- 's';
21 if cell.M.cb.T.s then str.[2] <- 's';
22 if cell.M.cb.T.w then str.[3] <- 's';
26 if cell.M.ck = "" then "<br/>" else cell.M.ck
28 let ind i = S.make (2 * i) ' '
30 let out_cell och cell =
31 let cc = border cell in
32 P.fprintf och "%s<td class=\"%s\">%s</td>\n"
33 (ind (i+4)) (S.concat " " cc) (key cell)
36 P.fprintf och "%s<tr>\n" (ind (i+3));
37 A.iter (out_cell och) row;
38 P.fprintf och "%s</tr>\n" (ind (i+3))
40 (****************************************************************************)
42 let open_out html name =
43 let fname = F.concat !O.output_dir (P.sprintf "%s.xsl" name) in
44 let och = open_out fname in
45 P.fprintf och "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\n";
46 P.fprintf och "<!-- %s -->\n\n" msg;
47 P.fprintf och "<xsl:stylesheet version=\"1.0\"\n";
48 P.fprintf och " xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\"\n";
49 if html then P.fprintf och " xmlns=\"http://www.w3.org/1999/xhtml\"\n";
50 P.fprintf och ">\n\n";
53 let output och name matrix =
54 P.fprintf och "<xsl:template name=\"%s\">\n" name;
55 P.fprintf och "%s<table cellpadding=\"4\" cellspacing=\"0\">\n" (ind (i+1));
56 P.fprintf och "%s<tbody>\n" (ind (i+2));
57 A.iter (out_row och) matrix.M.m;
58 P.fprintf och "%s</tbody>\n" (ind (i+2));
59 P.fprintf och "%s</table>\n" (ind (i+1));
60 P.fprintf och "</xsl:template>\n\n"
63 P.fprintf och "</xsl:stylesheet>\n";
66 let map_incs och name =
67 P.fprintf och "<xsl:include href=\"%s.xsl\"/>\n" name
69 let map_tbls och name =
70 P.fprintf och "%s<xsl:when test=\"@name='%s'\">\n" (ind (i+2)) name;
71 P.fprintf och "%s<xsl:call-template name=\"%s\"/>\n" (ind (i+3)) name;
72 P.fprintf och "%s</xsl:when>\n" (ind (i+2))
74 let write_hook name incs tbls =
75 let och = open_out false name in
76 L.iter (map_incs och) incs;
77 P.fprintf och "\n<xsl:template name=\"%s\">\n" name;
78 P.fprintf och "%s<xsl:choose>\n" (ind (i+1));
79 L.iter (map_tbls och) tbls;
80 P.fprintf och "%s</xsl:choose>\n" (ind (i+1));
81 P.fprintf och "</xsl:template>\n\n";