2
eval 'exec /usr/bin/env perl -S $0 ${1+"$@"}'
3
if $running_under_some_shell;
17
"inlinegraphic" => '',
26
$l =~ s/�/\à/g;
27
$l =~ s/�/\é/g;
29
$l =~ s/�/\è/g;
32
$l =~ s/�/\ù/g;
35
$l =~ s/�/\ç/g;
41
# variable globale pour la gestion des tags EMPTY
48
my @tags = split(/(\<)|(\/?\>)/) ;
51
for($i=0;$i <= $#tags;$i++) {
56
} elsif (/^(\/?\w+)/ && $take) {
57
#store in the array the tag name
61
if (exists $empty_tags{pop(@open_tags)}) {
62
#Here we have an empty tag end, just transform it.
63
$tags[$i] =~ s/\/\>/\>/g;
67
return join('',@tags);
72
local($xmlfile) = $_[0];
73
local($sgmlfile) = $_[1];
74
local($noheader) = $_[2];
77
my $SGML = "f$sgmlfile";
78
my $XML = "f$xmlfile";
80
print "$xmlfile -> $sgmlfile\n";
83
print "***Warning: $sgmlfile already exists\n";
84
system("mv $sgmlfile $sgmlfile~");
87
$sgmldir = dirname($sgmlfile);
88
if (not(-d $sgmldir)) {
89
print "***Warning: creating the directory $sgmldir\n";
90
system("mkdir -p $sgmldir");
93
open($XML, "<$xmlfile") || die "Cannot open $xmlfile\n";
94
open($SGML, ">$sgmlfile") || die "Cannot open $sgmlfile\n";
98
if (/\<\?xml .*\?\>/) {
99
#just skip the xml description type
102
if ($noheader == 0) {
103
#Don't print .dtd location for sgml
104
$line =~ s/\".*\.dtd\"//g;
105
if (/doctype/ || /DOCTYPE/) {
106
# Change the file header
107
$line =~ s/doctype/DOCTYPE/;
108
$line =~ s/DOCTYPE ([a-z]*) .*\"/DOCTYPE $1 $system/;
110
} elsif (/ENTITY.*\.xml/) {
112
# Get the included file name
113
($file = $line) =~ s/.*\"(.*)\.xml\".*\n/$1/;
115
# Output follows the main output path
116
$outfile = dirname($sgmlfile) . "/$file";
118
# The root file directory *is* the root directory
119
$outfile =~ s/\.\.\//dotdot\//g;
121
# Now the included file is the SGML one
122
$line =~ s/(.*)\"(.*)\.xml\"/$1\"$outfile.sgml\"/;
124
# Relative or absolute path?
125
if (not($file =~ /^\//)) {
126
$file = dirname($sgmlfile) . "/$file";
129
# The included files need not header
130
parse_xml("$file.xml", "$outfile.sgml", 1);
139
# Body of the document
142
# $line = parse_entities($line);
145
$line = parse_empty_tags($line);
159
print "$0 input.xml [output.sgml]\n";
163
$system = " PUBLIC \"-//OASIS//DTD DocBook V4.1.2//EN\"";
166
$sgmlfile = basename($xmlfile, '.xml');
167
$sgmlfile = dirname($xmlfile). "/$sgmlfile.sgml";
171
$sgmlfile = $ARGV[0];
174
parse_xml($xmlfile, $sgmlfile, 0);