223 |
$s; |
$s; |
224 |
} |
} |
225 |
|
|
226 |
|
sub parameter_entity_declaration ($$%) { |
227 |
|
my ($src, $Info, %opt) = @_; |
228 |
|
my $name = name_of $src, $Info, %opt; |
229 |
|
if (my $sysid = $src->get_attribute_value ('SYSTEM')) { |
230 |
|
if ($sysid =~ /^\s*<([^<>]+)>\s*$/) { |
231 |
|
$sysid = $1; |
232 |
|
$sysid =~ s/([%"])/sprintf '&#x%02X;', ord $1/ge; |
233 |
|
} elsif ($sysid =~ /^([^:]*):(.*)$/) { |
234 |
|
my $ns = $1; |
235 |
|
$sysid = $2; |
236 |
|
$sysid =~ s/([%"])/sprintf '&#x%02X;', ord $1/ge; |
237 |
|
$sysid = '%' . ($ns ? $ns . '.' : '') . 'sysid.base;' . $sysid; |
238 |
|
} else { |
239 |
|
$sysid = '%XHTML.sysid.base;' . $sysid; |
240 |
|
} |
241 |
|
my $r; |
242 |
|
if (my $pubid = $src->get_attribute_value ('PUBLIC')) { |
243 |
|
$r = qq{<!ENTITY % $name.sysid "$sysid">\n} . |
244 |
|
qq{<!ENTITY % $name.fpi "$pubid">\n} . |
245 |
|
qq{<!ENTITY % $name.fpi.defined "INCLUDE">\n}; |
246 |
|
} else { |
247 |
|
$r = qq{<!ENTITY % $name.sysid "$sysid">\n} . |
248 |
|
qq{<!ENTITY % $name.fpi "">\n} . |
249 |
|
qq{<!ENTITY % $name.fpi.defined "IGNORE">\n}; |
250 |
|
} |
251 |
|
return <<EOH; |
252 |
|
@{[get_desc ($src, $Info, prefix => qq(%$name: ), |
253 |
|
padding_length => 51, padding_dot => q(.), |
254 |
|
default => qq(%$name)) |
255 |
|
]}$r |
256 |
|
<![%$name.fpi.defined;[ |
257 |
|
<!ENTITY % $name.decl |
258 |
|
\t'PUBLIC "%$name.fpi;" |
259 |
|
\t\t"%$name.sysid;"'> |
260 |
|
]]> |
261 |
|
<!ENTITY % $name.decl |
262 |
|
\t'SYSTEM "%$name.sysid;"'> |
263 |
|
<!ENTITY % $name %$name.decl;> |
264 |
|
<!-- @{[dot_padding qq<%$name >, length => 51, dot => q<.>]} --> |
265 |
|
EOH |
266 |
|
} else { |
267 |
|
my $s = get_desc ($src, $Info); |
268 |
|
$s .= qq{<!ENTITY % $name } . |
269 |
|
paralit $src->get_attribute_value ('EntityValue'); |
270 |
|
$s .= ">\n"; |
271 |
|
return $s; |
272 |
|
} |
273 |
|
} |
274 |
|
|
275 |
sub dtd_driver ($$) { |
sub dtd_driver ($$) { |
276 |
my ($src, $Info) = @_; |
my ($src, $Info) = @_; |
277 |
my $s = ''; |
my $s = ''; |
286 |
push @module_set, $src; |
push @module_set, $src; |
287 |
} elsif ($src->local_name =~ /^(?:QName|Attribute|Datatype|Notation)Module/) { |
} elsif ($src->local_name =~ /^(?:QName|Attribute|Datatype|Notation)Module/) { |
288 |
$s{$src->local_name} .= dtd_driver_load_module ($src, $Info); |
$s{$src->local_name} .= dtd_driver_load_module ($src, $Info); |
289 |
|
|
290 |
} elsif ($src->local_name eq 'IfModuleSet') { |
} elsif ($src->local_name eq 'IfModuleSet') { |
291 |
$s .= qq(<![%@{[$src->get_attribute_value ('ModuleSet')]}.module;[\n); |
my $ms = name_of $src, $Info, key => $src->get_attribute_value ('ID') ? |
292 |
|
'ID' : 'ModuleSet'; |
293 |
|
$s .= qq(<![%$ms.module;[\n); |
294 |
|
$s .= submodule_declarations ($src, $Info); |
295 |
|
$s .= qq(<!-- end of $ms -->]]>\n\n); |
296 |
|
|
297 |
|
} elsif ($src->local_name eq 'IfModule') { |
298 |
|
my $ms = name_of $src, $Info, key => 'ID'; |
299 |
|
$s .= qq(<![%$ms.module;[\n); |
300 |
$s .= submodule_declarations ($src, $Info); |
$s .= submodule_declarations ($src, $Info); |
301 |
$s .= qq(]]>\n); |
$s .= qq(<!-- end of $ms -->]]>\n\n); |
302 |
|
} elsif ($src->local_name eq 'ElementSwitch') { |
303 |
|
$s .= qq(<!ENTITY % @{[name_of ($src, $Info)]}.element "@{[$src->get_attribute_value ('Use')>0?'INCLUDE':'IGNORE']}">\n); |
304 |
|
} elsif ($src->local_name eq 'AttributeSwitch') { |
305 |
|
$s .= qq(<!ENTITY % @{[name_of ($src, $Info)]}.attlist "@{[$src->get_attribute_value ('Use')>0?'INCLUDE':'IGNORE']}">\n); |
306 |
|
} elsif ($src->local_name eq 'ModuleSwitch') { |
307 |
|
$s .= qq(<!ENTITY % @{[name_of ($src, $Info)]}.module "@{[$src->get_attribute_value ('Use')>0?'INCLUDE':'IGNORE']}">\n); |
308 |
|
} elsif ($src->local_name eq 'Switch') { |
309 |
|
$s .= qq(<!ENTITY % @{[name_of ($src, $Info)]} "@{[$src->get_attribute_value ('Use')>0?'INCLUDE':'IGNORE']}">\n); |
310 |
} elsif ($src->local_name eq 'GeneralEntity') { |
} elsif ($src->local_name eq 'GeneralEntity') { |
311 |
$s .= entity_declaration ($src, $Info, param => 0); |
$s .= entity_declaration ($src, $Info, param => 0); |
312 |
} elsif ($src->local_name eq 'ParameterEntity') { |
} elsif ($src->local_name eq 'ParameterEntity') { |
313 |
$s .= entity_declaration ($src, $Info, param => 1); |
$s .= parameter_entity_declaration ($src, $Info); |
314 |
} |
} |
315 |
} |
} |
316 |
|
|
489 |
my $ID = $Info->{ID}; |
my $ID = $Info->{ID}; |
490 |
my $ns = $src->get_attribute ('Namespace'); |
my $ns = $src->get_attribute ('Namespace'); |
491 |
my $s = <<EOH; |
my $s = <<EOH; |
492 |
|
<!ENTITY % sgml.tag.minimizable "IGNORE"> |
493 |
|
|
494 |
<!ENTITY % NS.prefixed "@{[$ns->get_attribute_value ('UsePrefix')==1? |
<!ENTITY % NS.prefixed "@{[$ns->get_attribute_value ('UsePrefix')==1? |
495 |
q(INCLUDE):q(IGNORE)]}"> |
q(INCLUDE):q(IGNORE)]}"> |
496 |
|
|
546 |
|
|
547 |
<!-- The parameter entity %URI.datatype; should already be defined in |
<!-- The parameter entity %URI.datatype; should already be defined in |
548 |
Datatype module. --> |
Datatype module. --> |
549 |
<!ENTITY % URI.datatype; "CDATA"> |
<!ENTITY % URI.datatype "CDATA"> |
550 |
|
|
551 |
<![%$ID.prefixed;[ |
<![%$ID.prefixed;[ |
552 |
<!ENTITY % $ID.xmlns.decl.attrib |
<!ENTITY % $ID.xmlns.decl.attrib |
683 |
sub get_desc ($$;%) { |
sub get_desc ($$;%) { |
684 |
my ($src, $Info, %opt) = @_; |
my ($src, $Info, %opt) = @_; |
685 |
my $desc = $src->get_attribute_value ('Description'); |
my $desc = $src->get_attribute_value ('Description'); |
686 |
|
$desc =~ s/--/- - /g; |
687 |
$desc =~ s/\n/\n /g; |
$desc =~ s/\n/\n /g; |
688 |
if (length $desc) { |
if (length $desc) { |
689 |
$desc = qq($opt{prefix}$desc); |
$desc = qq($opt{prefix}$desc); |
803 |
} elsif ($src->local_name eq 'Content') { |
} elsif ($src->local_name eq 'Content') { |
804 |
$s .= element_content_def ($src, $Info); |
$s .= element_content_def ($src, $Info); |
805 |
} elsif ($src->local_name eq 'IfModuleSet') { |
} elsif ($src->local_name eq 'IfModuleSet') { |
806 |
$s .= qq(<![%@{[$src->get_attribute_value ('ModuleSet')]}.module;[\n); |
my $ms = name_of $src, $Info, key => $src->get_attribute_value ('ID') ? |
807 |
|
'ID' : 'ModuleSet'; |
808 |
|
$s .= qq(<![%$ms.module;[\n); |
809 |
$s .= submodule_declarations ($src, $Info); |
$s .= submodule_declarations ($src, $Info); |
810 |
$s .= qq(<!-- end of -->]]>\n); |
$s .= qq(<!-- end of $ms -->]]>\n\n); |
811 |
|
|
812 |
|
} elsif ($src->local_name eq 'IfModule') { |
813 |
|
my $ms = name_of $src, $Info, key => 'ID'; |
814 |
|
$s .= qq(<![%$ms.module;[\n); |
815 |
|
$s .= submodule_declarations ($src, $Info); |
816 |
|
$s .= qq(<!-- end of $ms -->]]>\n\n); |
817 |
} elsif ($src->local_name eq 'ElementSwitch') { |
} elsif ($src->local_name eq 'ElementSwitch') { |
818 |
$s .= qq(<!ENTITY % @{[name_of ($src, $Info)]}.element "@{[$src->get_attribute_value ('Use')>0?'INCLUDE':'IGNORE']}">\n); |
$s .= qq(<!ENTITY % @{[name_of ($src, $Info)]}.element "@{[$src->get_attribute_value ('Use')>0?'INCLUDE':'IGNORE']}">\n); |
819 |
} elsif ($src->local_name eq 'AttributeSwitch') { |
} elsif ($src->local_name eq 'AttributeSwitch') { |
820 |
$s .= qq(<!ENTITY % @{[name_of ($src, $Info)]}.attlist "@{[$src->get_attribute_value ('Use')>0?'INCLUDE':'IGNORE']}">\n); |
$s .= qq(<!ENTITY % @{[name_of ($src, $Info)]}.attlist "@{[$src->get_attribute_value ('Use')>0?'INCLUDE':'IGNORE']}">\n); |
821 |
} elsif ($src->local_name eq 'ModuleSwitch') { |
} elsif ($src->local_name eq 'ModuleSwitch') { |
822 |
$s .= qq(<!ENTITY % @{[name_of ($src, $Info)]}.module "@{[$src->get_attribute_value ('Use')>0?'INCLUDE':'IGNORE']}">\n); |
$s .= qq(<!ENTITY % @{[name_of ($src, $Info)]}.module "@{[$src->get_attribute_value ('Use')>0?'INCLUDE':'IGNORE']}">\n); |
823 |
|
} elsif ($src->local_name eq 'Switch') { |
824 |
|
$s .= qq(<!ENTITY % @{[name_of ($src, $Info)]} "@{[$src->get_attribute_value ('Use')>0?'INCLUDE':'IGNORE']}">\n); |
825 |
} elsif ($src->local_name eq 'GeneralEntity') { |
} elsif ($src->local_name eq 'GeneralEntity') { |
826 |
$s .= entity_declaration ($src, $Info, param => 0); |
$s .= entity_declaration ($src, $Info, param => 0); |
827 |
} elsif ($src->local_name eq 'ParameterEntity') { |
} elsif ($src->local_name eq 'ParameterEntity') { |
828 |
$s .= entity_declaration ($src, $Info, param => 1); |
$s .= parameter_entity_declaration ($src, $Info); |
829 |
|
} elsif ($src->local_name eq 'Module') { |
830 |
|
$s .= dtd_driver_load_module ($src, $Info); |
831 |
|
} elsif ($src->local_name eq 'DTD') { |
832 |
|
$s .= dtd_driver_load_dtd ($src, $Info); |
833 |
} |
} |
834 |
} |
} |
835 |
$s; |
$s; |
855 |
default => qq($short_name); |
default => qq($short_name); |
856 |
$s .= "\n"; |
$s .= "\n"; |
857 |
$s .= xml_parameter_ENTITY qq($mname.element), value => 'INCLUDE'; |
$s .= xml_parameter_ENTITY qq($mname.element), value => 'INCLUDE'; |
858 |
|
my $cm = convert_content_model ($src, $Info, default => 'EMPTY'); |
859 |
$s .= xml_condition_section (qq($mname.element) => |
$s .= xml_condition_section (qq($mname.element) => |
860 |
xml_parameter_ENTITY |
xml_parameter_ENTITY (qq($name.content), value => $cm) |
|
(qq($name.content), |
|
|
value => convert_content_model ($src, $Info, default => 'EMPTY')) |
|
861 |
. xml_parameter_ENTITY (qq($name.qname), value => $short_name) |
. xml_parameter_ENTITY (qq($name.qname), value => $short_name) |
862 |
. qq(<!ELEMENT %$name.qname; %$name.content;>\n)); |
. xml_parameter_ENTITY (qq($name.tagmin.start), value => q<->) |
863 |
|
. xml_parameter_ENTITY (qq($name.tagmin.end), value => $cm eq 'EMPTY' ? q<o> : q<->) |
864 |
|
. xml_condition_section (qq(sgml.tag.minimizable) => |
865 |
|
xml_parameter_ENTITY (qq($name.tagmin), |
866 |
|
value => qq"%$name.tagmin.start; %$name.tagmin.end;")) |
867 |
|
. xml_parameter_ENTITY (qq($name.tagmin), value => q"") |
868 |
|
. qq(<!ELEMENT %$name.qname; %$name.tagmin; %$name.content;>\n)); |
869 |
$s .= "\n"; |
$s .= "\n"; |
870 |
$s .= attlist_def (scalar $src->get_attribute ('Attribute', make_new_node => 1), $Info, $mname); |
$s .= attlist_def (scalar $src->get_attribute ('Attribute', make_new_node => 1), $Info, $mname); |
871 |
$s; |
$s; |
1058 |
|
|
1059 |
my $r = <<EOH; |
my $r = <<EOH; |
1060 |
<!-- ....................................................................... --> |
<!-- ....................................................................... --> |
1061 |
<!-- @{[ dot_padding "$Info->{Name} DTD ", length => 71, dot => q(.) ]} --> |
<!-- @{[do{ |
1062 |
|
my $s = qq($Info->{Name} DTD ); |
1063 |
|
if (70 - length $s > 0) { |
1064 |
|
$s = dot_padding $s, length => 70, dot => q(.); |
1065 |
|
} else { |
1066 |
|
$s = qq( $Info->{Version} DTD ); |
1067 |
|
$s = qq($Info->{realname}\n ) . dot_padding $s, length => 70, dot => q(.); |
1068 |
|
} |
1069 |
|
$s; |
1070 |
|
}]} --> |
1071 |
<!-- file: $Info->{ID}.dtd |
<!-- file: $Info->{ID}.dtd |
1072 |
--> |
--> |
1073 |
|
|