X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Fwww%2Flambdadelta%2Fbin%2Fxhtbl%2FxmlUnparser.ml;h=2f29e4bb728192f22c7f5142428826d63013597e;hb=9a0dc83131e9695ffd4254ff5546817ca431d8c2;hp=3583c2f7536e95d045a4dd0776bbf81d4169b8c2;hpb=2a5e0b799cd6aae5d920c67a5ddc9d9888cf7e80;p=helm.git diff --git a/helm/www/lambdadelta/bin/xhtbl/xmlUnparser.ml b/helm/www/lambdadelta/bin/xhtbl/xmlUnparser.ml index 3583c2f75..2f29e4bb7 100644 --- a/helm/www/lambdadelta/bin/xhtbl/xmlUnparser.ml +++ b/helm/www/lambdadelta/bin/xhtbl/xmlUnparser.ml @@ -8,12 +8,22 @@ module O = Options module T = Table module M = Matrix +let xhtbl = "xhtbl" + let i = 0 let myself = F.basename (Sys.argv.(0)) let msg = P.sprintf "This file was generated by %s, do not edit" myself +let compose uri ext = + if uri.[pred (S.length uri)] = '/' then uri else + try + let i = S.index uri '#' in + let uri, fragment = S.sub uri 0 i, S.sub uri i (S.length uri - i) in + uri ^ ext ^ fragment + with Not_found -> uri ^ ext + let border cell = let str = S.make 4 'n' in if cell.M.cb.T.n then str.[0] <- 's'; @@ -22,40 +32,52 @@ let border cell = if cell.M.cb.T.w then str.[3] <- 's'; str :: cell.M.cc +let text baseuri ext = function + | T.Plain s -> s + | T.Link (true, uri, s) -> P.sprintf "%s" uri s + | T.Link (false, uri, s) -> + let uri = !O.baseuri ^ baseuri ^ compose uri ext in + P.sprintf "%s" uri s + +let name cell = + if cell.M.cn = "" then "" else P.sprintf " id=\"%s\"" cell.M.cn + let key cell = - if cell.M.ck = [] then "
" else S.concat " " cell.M.ck + if cell.M.ck = [] then "
" else S.concat "" (L.map (text cell.M.cu cell.M.cx) cell.M.ck) let ind i = S.make (2 * i) ' ' let out_cell och cell = - let cc = border cell in - P.fprintf och "%s%s\n" - (ind (i+4)) (S.concat " " cc) (key cell) + let cc = xhtbl :: border cell in + P.fprintf och "%s%s\n" + (ind (i+3)) (S.concat " " cc) (name cell) (key cell) let out_row och row = - P.fprintf och "%s\n" (ind (i+3)); + P.fprintf och "%s\n" (ind (i+2)) xhtbl; A.iter (out_cell och) row; - P.fprintf och "%s\n" (ind (i+3)) + P.fprintf och "%s\n" (ind (i+2)) + +let out_space och (name, uri) = + let name = if name = "" then name else ":" ^ name in + P.fprintf och " xmlns%s=\"%s\"\n" name uri (****************************************************************************) -let open_out html name = +let open_out name spaces = let fname = F.concat !O.output_dir (P.sprintf "%s.xsl" name) in + let spaces = ("xsl", "http://www.w3.org/1999/XSL/Transform") :: spaces in let och = open_out fname in P.fprintf och "\n\n"; P.fprintf och "\n\n" msg; P.fprintf och "\n\n"; och let output och name matrix = P.fprintf och "\n" name; - P.fprintf och "%s\n" (ind (i+1)); - P.fprintf och "%s\n" (ind (i+2)); - A.iter (out_row och) matrix.M.m; - P.fprintf och "%s\n" (ind (i+2)); + P.fprintf och "%s
\n" (ind (i+1)) xhtbl; + A.iter (out_row och) matrix.M.m; P.fprintf och "%s
\n" (ind (i+1)); P.fprintf och "
\n\n" @@ -72,7 +94,7 @@ let map_tbls och name = P.fprintf och "%s\n" (ind (i+2)) let write_hook name incs tbls = - let och = open_out false name in + let och = open_out name [] in L.iter (map_incs och) incs; P.fprintf och "\n\n" name; P.fprintf och "%s\n" (ind (i+1));