#!/perl/bin/perl # # dtd2htm.pl -- simple approach to convert .dtd to .html. use strict; use warnings; use diagnostics; use XML::DTDParser qw(ParseDTD); use Data::Dumper; open DTD, $ARGV[0] or die "Cannot open $ARGV[0] : $!\n"; my $DTDtext; { local $/; $DTDtext = } close DTD; my $DTD = ParseDTD $DTDtext; if ($ARGV[1]) { print Dumper($DTD); exit; } print < $ARGV[0]

$ARGV[0]

Table of Contents

BP for (sort keys %$DTD) { print "\n"; print " \n"; print "\n"; } print <
Name
$_
Legend
  The absence of a cardinality operator character indicates that one, and only one, instance of the child element is allowed (and is required).
? Zero or one instance—optional singular element
* Zero or more instances—optional element(s)
+ One or more instances—required element(s)

BP for (sort keys %$DTD) { my $ref = $$DTD{$_}; print <

$_

BP if ($$ref{'childrenSTR'}) { print "\n"; print " \n"; if (exists($$ref{'children'})) { my $children = $$ref{'children'}; print " \n"; print "\n"; my $rows = scalar(keys %$children) + 1; print < BP for (sort keys %$children) { my $cardinality = $$children{$_}; print "\n"; if ($cardinality ne '!') { print " \n"; } else { print " \n"; } print "\n"; } } else { print " \n"; } print "\n"; } else { print "\n"; print " \n"; print " \n"; print "\n"; } if ($$ref{'attributes'}) { my $list = $$ref{'attributes'}; my $rows = scalar(keys %$list) + 1; print < BP for (keys %{$list}) { print "\n"; print " \n"; my $arrayref = $$list{$_}; if ($$arrayref[0] =~ /\|/) { print " \n"; print " \n"; } else { print " \n"; print " \n"; } if ($$arrayref[1]) { print " \n"; } else { print " \n"; } if ($$arrayref[2]) { print " \n"; } else { print " \n"; } print "\n"; } } if ($$ref{'parent'}) { print "\n"; print " \n"; print "\n"; my $list = $$ref{'parent'}; for (@$list) { print "\n"; print "\n"; print "\n"; } } print "
Name Content Category/Model
$_A List of:
  Name
$_$cardinality$_
$$ref{'childrenSTR'}
$_EMPTY
  Name Type Values Presence Default
$_ $$arrayref[0]$$arrayref[0] $$arrayref[1] $$arrayref[2] 
Parents (Used by)
$_
\n"; print "
\n"; } print < BP