1 let html_header = format_of_string
3 PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"
4 \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">
5 <html xmlns=\"http://www.w3.org/1999/xhtml\" >
8 <meta http-equiv=\"content-type\" content=\"text/html;
10 <style type=\"text/css\" media=\"all\">
25 span a { text-decoration:underline; }
28 div[class=\"touched\"] {
30 text-decoration: none;
33 div[class=\"touched_text\"] {
35 background-color: #00a;
41 div[class=\"selected\"] {
47 div[class=\"selected_text\"] {
49 background-color: #00f;
54 div[class=\"skipped_text\"] {
61 div[class=\"skipped\"] {
66 div:hover[class=\"skipped\"] {
75 div[id=\"tooltipzone\"] span {
77 text-decoration: none;
78 font-family: monospace;
92 div[class=\"header\"]{
99 background-color: white;
102 font-family: monospace;
107 div[class=\"document\"] {
114 font-family: monospace;
119 div[class=\"yellow\"] {
135 <script type=\"text/javascript\">
136 function ShowPopup(span)
139 ttz = document.getElementById('tooltipzone');
140 children = ttz.childNodes;
141 if (children.length == 1){
143 newid = \"div\" + id.substring(2);
144 div = document.getElementById(newid);
145 div.appendChild(children[0]);
147 ttz.appendChild(span);
154 let html_footer = "</div> <!-- document -->
157 let h_trace = Hashtbl.create 4096
158 let r_trace = Hashtbl.create 4096
159 let register_trace tree t x =
160 Hashtbl.add h_trace (Tree.id tree t) x
162 module HFname = Hashtbl.Make (struct
164 let hash = Hashtbl.hash
168 let h_fname = HFname.create 401
170 let register_funname f s =
171 HFname.add h_fname (Obj.repr f) s
172 let get_funname f = try HFname.find h_fname (Obj.repr f) with _ -> "[anon_fun]"
174 let s = Tag.to_string tag in
176 for i=0 to (String.length s)-1 do
178 | '<' | '>' -> incr num
184 let ns = String.create ((String.length s)+3 * !num) in
185 for i=0 to (String.length s)-1 do
189 ns.[!j+1] <- (if x == '>' then 'g' else 'l') ;
193 | _ -> ns.[!j] <- s.[i]; incr j
198 let output_trace a tree file results =
199 let h_auto = 6+ (Hashtbl.fold (fun _ l a -> (List.length l)+a) a.trans 0) in
200 let max_tt = ref 0 in
201 let outc = open_out file in
202 let outf = Format.formatter_of_out_channel outc in
203 let strf = Format.str_formatter in
204 let pr_str x = Format.fprintf strf x in
205 let pr_out x = Format.fprintf outf x in
207 if not (Tree.is_nil t) then
208 let id = Tree.id tree t in
209 let tag = Tree.tag tree t in
210 let tooltip,selected = try
211 let (inconf,outconf,trans,first_fun,next_fun,ctx) = Hashtbl.find h_trace id in
212 let selected = IntSet.mem id results in
213 pr_str "<span id=\"id%i\"><table><tr><td>Subtree %i, tag='%s', internal node = %s\n"
214 id id (tag_to_str tag) (Tree.dump_node t);
215 pr_str "Context node is %i, tag='%s', internal node = '%s'\n"
216 (Tree.id tree ctx) (tag_to_str (Tree.tag tree ctx)) (Tree.dump_node ctx);
217 pr_str "%s" "\nEntered with configuration:\n";
218 SList.iter (fun s -> StateSet.print strf s) inconf;
219 pr_str "%s" "\nLeft with configuration:\n";
220 SList.iter (fun s -> StateSet.print strf s) outconf;
221 (let ft = first_fun t in
222 pr_str "\n<a href=\"#l%i\" onclick=\"ShowPopup(document.getElementById('id%i'));\" >Left successor</a> is: id=%i, tag='%s', internal node = '%s'\n"
223 (Tree.id tree ft) (Tree.id tree ft) (Tree.id tree ft) (tag_to_str (Tree.tag tree ft)) (Tree.dump_node ft);
224 pr_str "Moving with : %s (tree=%i)\n" (get_funname first_fun) id;
226 (let nt = next_fun t ctx in
227 pr_str "\n<a href=\"#l%i\" onclick=\"ShowPopup(document.getElementById('id%i'));\">Right successor</a> is: id=%i, tag='%s', internal node = '%s'\n"
228 (Tree.id tree nt) (Tree.id tree nt) (Tree.id tree nt) (tag_to_str (Tree.tag tree nt)) (Tree.dump_node nt);
229 pr_str "Moving with : %s (tree=%i) (ctx=%i)\n" (get_funname next_fun) id (Tree.id tree ctx);
231 pr_str "%s" "\nTriggered transitions:\n";
232 pr_str "%s" "<table><tr valign=\"top\">";
233 Formlistlist.iter (fun fl ->
234 pr_str "%s" "<td>";Formlist.print strf fl;pr_str "</td>";
235 max_tt := max !max_tt (Formlist.length fl);
237 pr_str "%s" "</td></table>\n";
238 pr_str "In result set : %s\n</td></tr></table></span>" (if selected then "Yes" else "No");
239 Format.flush_str_formatter(),selected
241 Not_found -> "",false
243 let div_class = (if (tooltip = "") then "skipped" else (if selected then "selected" else "touched"))^
244 (if tag == Tag.pcdata || tag== Tag.attribute_data then "_text" else"")
246 if tag == Tag.pcdata || tag== Tag.attribute_data then
247 pr_out "<div class=\"%s\"><a name=\"l%i\"/>%s%s</div>" div_class id (Tree.get_text tree t) tooltip
249 if (Tree.is_nil (Tree.first_child tree t))
251 pr_out "<div class=\"%s\" id=\"div%i\" onclick=\"ShowPopup(document.getElementById('id%i'));\"><a name=\"l%i\"/><%s/>%s</div>"
252 div_class id id id (tag_to_str tag) tooltip
254 pr_out "<div class=\"%s\" id=\"div%i\" onclick=\"ShowPopup(document.getElementById('id%i'));\"><a name=\"l%i\"/><%s>%s</div>"
255 div_class id id id (tag_to_str tag) tooltip;
256 loop (Tree.first_child tree t);
258 pr_out "<div class=\"%s\"></%s></div>" div_class (tag_to_str tag)
260 pr_out "<a href=\"#l%i\" onclick=\"ShowPopup(document.getElementById('id%i'));\"><div class=\"%s\"></%s></div></a>" id id div_class (tag_to_str tag);
263 loop (Tree.next_sibling tree t);
265 let max_tt = 25*(!max_tt + 15)+20 in
266 let height = max max_tt (25*h_auto) in
267 pr_out html_header height height height height;
268 pr_out "%s" "<div class=\"header\">";
269 pr_out "query: %s\n" a.query_string;
271 pr_out "%s" "</div><hr /><div class=\"yellow\" id=\"tooltipzone\"></div>";
272 pr_out "%s" "<div class=\"document\">";
274 pr_out "%s" html_footer;