Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
cduce
cduce
Commits
a23bf52a
Commit
a23bf52a
authored
Oct 05, 2007
by
Pietro Abate
Browse files
[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
Changes
1
Hide whitespace changes
Inline
Side-by-side
tools/dtd2cduce.ml
View file @
a23bf52a
(* 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
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment