Skip to content

Commit

Permalink
Try new W3C Feed Validator parser
Browse files Browse the repository at this point in the history
  • Loading branch information
dinosaure committed Apr 14, 2015
1 parent 1fdb0f7 commit bd4eadd
Showing 1 changed file with 10 additions and 48 deletions.
58 changes: 10 additions & 48 deletions bin/main.ml
Original file line number Diff line number Diff line change
@@ -1,53 +1,15 @@
open Syndic.Opml1
open Printf

(* let () = *)

(* Printexc.record_backtrace true; *)

(* try let _ = Atom.parse (Xmlm.make_input (`Channel stdin)) in () *)
(* with *)
(* | Atom.Error.Error (pos, err) -> *)
(* print_endline err *)
(* | _ -> Printexc.print_backtrace stderr *)

let iter_opt o f =
match o with
| None -> ()
| Some x -> f x

let print_head h =
printf "Title : %s\n" h.title;
iter_opt h.date_created (fun d -> printf "Date Creation : %f\n"
(CalendarLib.Calendar.to_unixfloat d));
printf "Date Modified : %f\n"
(CalendarLib.Calendar.to_unixfloat h.date_modified);
printf "Name %s\n" h.owner_name;
printf "Email %s\n" h.owner_email;
printf "Expansion State [%s]\n"
(String.concat ", " (List.map string_of_int h.expansion_state));
iter_opt h.window_top (fun i -> printf "Window Top %d\n" i);
iter_opt h.window_left (fun i -> printf "Window Left %d\n" i);
iter_opt h.window_bottom (fun i -> printf "Window Bottom %d\n" i);
iter_opt h.window_right (fun i -> printf "Window Right %d\n" i)

let rec print_outline level o =
printf "%s Text %s\n" level o.text;
List.iter (print_outline "Sub") o.outlines

let print_body b =
List.iter (print_outline "High") b

let print_opml1 o =
printf "Version : %s\n" o.version;
print_head o.head;
print_body o.body
open Syndic

let () =

Printexc.record_backtrace true;

try let o = parse (Xmlm.make_input (`Channel stdin)) in print_opml1 o
try let lst = W3C.parse (Xmlm.make_input (`Channel stdin)) in
List.iter
(fun (_, err) -> Printf.printf "E: %s\n%!" err)
(List.map Syndic.W3C.to_error lst)
with
| Error.Error (pos, err) ->
print_endline err
| _ -> Printexc.print_backtrace stderr
| W3C.Error.Error ((l, c), err) ->
Printf.printf "[%d;%d]: %s\n%!"
l c err
| _ -> Printexc.print_backtrace stderr

0 comments on commit bd4eadd

Please sign in to comment.