- (** pretty print a MathQL query result to a string *)
-let text_of_result result sep =
- let res_string = ref "" in
- let app = function s -> res_string := !res_string ^ s in
- MQueryUtil.text_of_result app result sep ;
- !res_string
+ (** pretty print a MathQL query result to an HELM theory file *)
+let theory_of_result result =
+ let results_no = List.length result in
+ if results_no > 0 then
+ let mode = if results_no > 10 then "linkonly" else "typeonly" in
+ let results =
+ let idx = ref (results_no + 1) in
+ List.fold_right
+ (fun (uri,attrs) i ->
+ decr idx ;
+ "<tr><td valign=\"top\">" ^ string_of_int !idx ^ ".</td><td><ht:OBJECT uri=\"" ^ uri ^ "\" mode=\"" ^ mode ^ "\"/></td></tr>" ^ i
+ ) result ""
+ in
+ "<h1>Query Results:</h1><table xmlns:ht=\"http://www.cs.unibo.it/helm/namespaces/helm-theory\">" ^ results ^ "</table>"
+ else
+ "<h1>Query Results:</h1><p>No results found!</p>"
+;;
+
+let pp_result result =
+ "<html xmlns:ht=\"http://www.cs.unibo.it/helm/namespaces/helm-theory\">\n<head><title>Query Results</title><style> A { text-decoration: none } </style></head>\n<body>" ^ theory_of_result result ^ "</body></html>"