Commit a23bf52a authored by Pietro Abate's avatar Pietro Abate

[r2003-05-11 09:07:01 by cvscast] dtd2cduce now takes a DTD

Original author: cvscast
Date: 2003-05-11 09:07:01+00:00
parent c141b0a1
(* TODO:
- attributes !
- clever factorizations of content model and attribute specifs
(e.g. type XHTML_inlien = [ ( Char | ... ) ])
- better pretty-printing
......@@ -87,36 +86,16 @@ let import_dtd ppf name filename =
attrib e
content (e # content_model)
in
let handle = function
| E_start_doc(_,_,dtd) ->
List.iter (fun x -> elt ppf (dtd # element x)) (dtd # element_names);
exit 0
| E_error e ->
printf "Error: %s\n" (Pxp_types.string_of_exn e);
exit 2
| _ -> ()
in
let config = default_config in
let mgr = create_entity_manager config (from_file filename) in
let next_event =
create_pull_parser config (`Entry_document [`Extend_dtd_fully]) mgr in
let event = ref (Some E_end_of_stream) in
let dtd = parse_dtd_entity default_config (from_file filename) in
Format.fprintf ppf
"(* This type has been automatically generated from %s by dtd2cduce *)@\n"
filename;
let rec loop () =
match next_event () with
| None -> failwith "End of file reached before DTD definition"
| Some e -> handle e; loop ()
in
loop ()
List.iter (fun x -> elt ppf (dtd # element x)) (dtd # element_names)
let () =
if Array.length Sys.argv <> 3 then
(prerr_endline "Usage: dtd2cduce <prefix> <.dtd file>";
exit 2);
let name s = Sys.argv.(1) ^ s in
import_dtd Format.std_formatter name Sys.argv.(2)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment