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 register_trace t x = Hashtbl.add h_trace (Tree.id t) x
159 let h_fname = Hashtbl.create 401
161 let register_funname f s = Hashtbl.add h_fname (Hashtbl.hash f) s
162 let get_funname f = try Hashtbl.find h_fname (Hashtbl.hash f) with _ -> "[anon_fun]"
164 let s = Tag.to_string tag in
166 for i=0 to (String.length s)-1 do
168 | '<' | '>' -> incr num
174 let ns = String.create ((String.length s)+3 * !num) in
175 for i=0 to (String.length s)-1 do
179 ns.[!j+1] <- (if x == '>' then 'g' else 'l') ;
183 | _ -> ns.[!j] <- s.[i]; incr j
188 let output_trace a t file results =
189 let h_auto = 6+ (Hashtbl.fold (fun _ l a -> (List.length l)+a) a.trans 0) in
190 let max_tt = ref 0 in
191 let outc = open_out file in
192 let outf = Format.formatter_of_out_channel outc in
193 let strf = Format.str_formatter in
194 let pr_str x = Format.fprintf strf x in
195 let pr_out x = Format.fprintf outf x in
197 if not (Tree.is_nil t) then
198 let id = Tree.id t in
199 let tag = Tree.tag t in
200 let tooltip,selected = try
201 let (inconf,outconf,trans,first_fun,next_fun,ctx) = Hashtbl.find h_trace id in
202 let selected = IntSet.mem id results in
203 pr_str "<span id=\"id%i\"><table><tr><td>Subtree %i, tag='%s', internal node = %s\n"
204 id id (tag_to_str tag) (Tree.dump_node t);
206 pr_str "Context node is %i, tag='%s', internal node = '%s'\n"
207 (Tree.id ctx) (tag_to_str (Tree.tag ctx)) (Tree.dump_node ctx);
208 pr_str "%s" "\nEntered with configuration:\n";
209 SList.iter (fun s -> StateSet.print strf s) inconf;
210 pr_str "%s" "\nLeft with configuration:\n";
211 SList.iter (fun s -> StateSet.print strf s) outconf;
212 (let ft = first_fun t in
213 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"
214 (Tree.id ft) (Tree.id ft) (Tree.id ft) (tag_to_str (Tree.tag ft)) (Tree.dump_node ft);
215 pr_str "Moving with : %s (tree=%i)\n" (get_funname first_fun) id;
217 (let nt = next_fun t ctx in
218 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"
219 (Tree.id nt) (Tree.id nt) (Tree.id nt) (tag_to_str (Tree.tag nt)) (Tree.dump_node nt);
220 pr_str "Moving with : %s (tree=%i) (ctx=%i)\n" (get_funname first_fun) id (Tree.id ctx);
222 pr_str "%s" "\nTriggered transitions:\n";
223 pr_str "%s" "<table><tr valign=\"top\">";
225 pr_str "%s" "<td>";Formlist.print strf fl;pr_str "</td>";
226 max_tt := max !max_tt (Formlist.length fl);
228 pr_str "%s" "</td></table>\n";
229 pr_str "In result set : %s\n</td></tr></table></span>" (if selected then "Yes" else "No");
230 Format.flush_str_formatter(),selected
232 Not_found -> "",false
234 let div_class = (if (tooltip = "") then "skipped" else (if selected then "selected" else "touched"))^
235 (if tag == Tag.pcdata || tag== Tag.attribute_data then "_text" else"")
237 if tag == Tag.pcdata || tag== Tag.attribute_data then
238 pr_out "<div class=\"%s\"><a name=\"l%i\"/>%s%s</div>" div_class id (Tree.get_text t) tooltip
240 if (Tree.is_nil (Tree.first_child t))
242 pr_out "<div class=\"%s\" id=\"div%i\" onclick=\"ShowPopup(document.getElementById('id%i'));\"><a name=\"l%i\"/><%s/>%s</div>"
243 div_class id id id (tag_to_str tag) tooltip
245 pr_out "<div class=\"%s\" id=\"div%i\" onclick=\"ShowPopup(document.getElementById('id%i'));\"><a name=\"l%i\"/><%s>%s</div>"
246 div_class id id id (tag_to_str tag) tooltip;
247 loop (Tree.first_child t);
249 pr_out "<div class=\"%s\"></%s></div>" div_class (tag_to_str tag)
251 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);
254 loop (Tree.next_sibling t);
256 let max_tt = 25*(!max_tt + 15)+20 in
257 let height = max max_tt (25*h_auto) in
258 pr_out html_header height height height height;
259 pr_out "%s" "<div class=\"header\">";
260 pr_out "query: %s\n" a.query_string;
262 pr_out "%s" "</div><hr /><div class=\"yellow\" id=\"tooltipzone\"></div>";
263 pr_out "%s" "<div class=\"document\">";
265 pr_out "%s" html_footer;