| 1 |
# -*- Perl -*- |
| 2 |
|
| 3 |
# dtdformat module for RefEntrys for DB:TDG |
| 4 |
|
| 5 |
my $VERSION = "SF DocBook 1.0"; |
| 6 |
|
| 7 |
my $PUBLIC_ID = "-//OASIS//DTD DocBook XML V4.1.2//EN"; |
| 8 |
my $SYSTEM_ID = "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd"; |
| 9 |
|
| 10 |
my $prefix = ""; |
| 11 |
|
| 12 |
my @common_attributes = ('xml:base', |
| 13 |
'dir', |
| 14 |
'id', |
| 15 |
'role', |
| 16 |
'lang', |
| 17 |
'remap', |
| 18 |
'xreflabel', |
| 19 |
'revisionflag', |
| 20 |
'arch', |
| 21 |
'conformance', |
| 22 |
'os', |
| 23 |
'revision', |
| 24 |
'userlevel', |
| 25 |
'vendor', |
| 26 |
'security', |
| 27 |
'condition'); |
| 28 |
|
| 29 |
$fileext = ".xml"; |
| 30 |
$libdir = "/sourceforge/docbook/defguide/en/build/lib"; |
| 31 |
|
| 32 |
$config{'expanded-element-index'} = "elements"; |
| 33 |
$config{'unexpanded-element-index'} = "dtdelem"; |
| 34 |
$config{'expanded-entity-index'} = "entities"; |
| 35 |
$config{'unexpanded-entity-index'} = "dtdent"; |
| 36 |
$config{'expanded-entity-dir'} = 'paraments'; |
| 37 |
$config{'unexpanded-entity-dir'} = 'paraments'; |
| 38 |
$config{'notation-index'} = 'notations'; |
| 39 |
|
| 40 |
$option{'base-id'} = 'dbre'; |
| 41 |
$option{'base-dir'} = "$libdir/../../refpages"; |
| 42 |
$option{'seealso'} = 1; |
| 43 |
|
| 44 |
my %entity_classes = (); |
| 45 |
my @entity_classes = (); |
| 46 |
my @entity_pats = (); |
| 47 |
|
| 48 |
my %revision = ('productionset' => 'EBNF', |
| 49 |
'production' => 'EBNF', |
| 50 |
'lhs' => 'EBNF', |
| 51 |
'rhs' => 'EBNF', |
| 52 |
'nonterminal' => 'EBNF', |
| 53 |
'constraint' => 'EBNF', |
| 54 |
'productionrecap' => 'EBNF', |
| 55 |
'constraintdef' => 'EBNF', |
| 56 |
|
| 57 |
'bibliocoverage' => '4.2', |
| 58 |
'biblioid' => '4.2', |
| 59 |
'bibliorelation' => '4.2', |
| 60 |
'bibliosource' => '4.2', |
| 61 |
'blockinfo' => '4.2', |
| 62 |
'citebiblioid' => '4.2', |
| 63 |
'coref' => '4.2', |
| 64 |
'errortext' => '4.2', |
| 65 |
'personblurb' => '4.2', |
| 66 |
'personname' => '4.2', |
| 67 |
'refsection' => '4.2', |
| 68 |
'refsectioninfo' => '4.2', |
| 69 |
'textdata' => '4.2', |
| 70 |
|
| 71 |
'appendixinfo' => '4.0', |
| 72 |
'articleinfo' => '4.0', |
| 73 |
'bibliographyinfo' => '4.0', |
| 74 |
'chapterinfo' => '4.0', |
| 75 |
'classsynopsis' => '4.0', |
| 76 |
'classsynopsisinfo' => '4.0', |
| 77 |
'constructorsynopsis' => '4.0', |
| 78 |
'destructorsynopsis' => '4.0', |
| 79 |
'exceptionname' => '4.0', |
| 80 |
'fieldsynopsis' => '4.0', |
| 81 |
'glossaryinfo' => '4.0', |
| 82 |
'indexinfo' => '4.0', |
| 83 |
'initializer' => '4.0', |
| 84 |
'interfacename' => '4.0', |
| 85 |
'methodname' => '4.0', |
| 86 |
'methodparam' => '4.0', |
| 87 |
'methodsynopsis' => '4.0', |
| 88 |
'modifier' => '4.0', |
| 89 |
'ooclass' => '4.0', |
| 90 |
'ooexception' => '4.0', |
| 91 |
'oointerface' => '4.0', |
| 92 |
'partinfo' => '4.0', |
| 93 |
'prefaceinfo' => '4.0', |
| 94 |
'refentryinfo' => '4.0', |
| 95 |
'referenceinfo' => '4.0', |
| 96 |
'remark' => '4.0', |
| 97 |
'revdescription' => '4.0', |
| 98 |
'setindexinfo' => '4.0', |
| 99 |
'sidebarinfo' => '4.0', |
| 100 |
'simplemsgentry' => '4.0', |
| 101 |
|
| 102 |
'mediaobject' => '3.1', |
| 103 |
'mediaobjectco' => '3.1', |
| 104 |
'inlinemediaobject' => '3.1', |
| 105 |
'videoobject' => '3.1', |
| 106 |
'audioobject' => '3.1', |
| 107 |
'imageobject' => '3.1', |
| 108 |
'imageobjectco' => '3.1', |
| 109 |
'textobject' => '3.1', |
| 110 |
'objectinfo' => '3.1', |
| 111 |
'videodata' => '3.1', |
| 112 |
'audiodata' => '3.1', |
| 113 |
'imagedata' => '3.1', |
| 114 |
'caption' => '3.1', |
| 115 |
'informalfigure' => '3.1', |
| 116 |
'colophon' => '3.1', |
| 117 |
'section' => '3.1', |
| 118 |
'sectioninfo' => '3.1', |
| 119 |
'qandaset' => '3.1', |
| 120 |
'qandadiv' => '3.1', |
| 121 |
'qandaentry' => '3.1', |
| 122 |
'question' => '3.1', |
| 123 |
'answer' => '3.1', |
| 124 |
'constant' => '3.1', |
| 125 |
'varname' => '3.1'); |
| 126 |
|
| 127 |
# ====================================================================== |
| 128 |
{ |
| 129 |
print "\nLoading parament classes..."; |
| 130 |
|
| 131 |
local *F, $_; |
| 132 |
my $class, $regexp; |
| 133 |
my %classes = (); |
| 134 |
open (F, "$libdir/parament.classes"); |
| 135 |
while (<F>) { |
| 136 |
chop; |
| 137 |
if (/^\s+(\S+)/) { |
| 138 |
$entity_classes{$1} = $class; |
| 139 |
} elsif (/^(\S+)\s+(\S+)/) { |
| 140 |
$class = $1; |
| 141 |
$regexp = $2; |
| 142 |
$regexp =~ s/\./\\\./g; |
| 143 |
$regexp =~ s/\*/\.\*/g; |
| 144 |
push(@entity_classes, $class); |
| 145 |
push(@entity_pats, $regexp); |
| 146 |
$classes{$class} = 1; |
| 147 |
} elsif (/^(\S+)\s*$/) { |
| 148 |
$class = $1; |
| 149 |
$classes{$class} = 1; |
| 150 |
} else { |
| 151 |
warn "Unexpected line in parament.classes: $_\n"; |
| 152 |
} |
| 153 |
} |
| 154 |
|
| 155 |
print "\nCleaning up parament class files..."; |
| 156 |
|
| 157 |
foreach $class (keys %classes) { |
| 158 |
my $basedir = $option{'base-dir'}; |
| 159 |
my $path = $basedir . "/" . $config{'expanded-entity-dir'}; |
| 160 |
unlink("$path/$class.e.gen"); |
| 161 |
$path = $basedir . "/" . $config{'unexpanded-entity-dir'}; |
| 162 |
unlink("$path/$class.u.gen"); |
| 163 |
} |
| 164 |
} |
| 165 |
|
| 166 |
END { |
| 167 |
# Now that we've written out all those parameter entity files, |
| 168 |
# make sure the entities in them are sorted... |
| 169 |
|
| 170 |
&status("Sorting entities...",1); |
| 171 |
|
| 172 |
my $basedir = $option{'base-dir'}; |
| 173 |
my $path = $basedir . "/" . $config{'expanded-entity-dir'}; |
| 174 |
opendir (DIR, $path); |
| 175 |
while (my $name = readdir(DIR)) { |
| 176 |
my $file = "$path/$name"; |
| 177 |
next if $name !~ /\.gen$/; |
| 178 |
next if -d $file; |
| 179 |
open (F, $file); |
| 180 |
read (F, $_, -s $file); |
| 181 |
close (F); |
| 182 |
|
| 183 |
my %refsects = (); |
| 184 |
while (/<refsect2.*?id=([\'\"])(.*?)\1.*?<\/refsect2>\s+/s) { |
| 185 |
my $sect = $&; |
| 186 |
my $id = $2; |
| 187 |
$_ = $` . $'; # ' |
| 188 |
die "Duplicate refsect ID: $2\n" if $refsects{$id}; |
| 189 |
$refsects{$id} = $sect; |
| 190 |
} |
| 191 |
|
| 192 |
die "Unexpected content in $file: $_\n" if !/^\s*$/s; |
| 193 |
|
| 194 |
open (F, ">$file"); |
| 195 |
foreach my $id (sort keys %refsects) { |
| 196 |
print F $refsects{$id}; |
| 197 |
} |
| 198 |
close (F); |
| 199 |
} |
| 200 |
closedir (DIR); |
| 201 |
|
| 202 |
print "\n"; |
| 203 |
|
| 204 |
} |
| 205 |
|
| 206 |
# ====================================================================== |
| 207 |
|
| 208 |
sub elementRefpurpose { |
| 209 |
my $count = shift; |
| 210 |
my $name = $elements[$count]; |
| 211 |
|
| 212 |
return "&$name.purpose;"; |
| 213 |
} |
| 214 |
|
| 215 |
sub entityRefpurpose { |
| 216 |
my $count = shift; |
| 217 |
my $name = $entities[$count]; |
| 218 |
my $entity = $entities{$name}; |
| 219 |
|
| 220 |
return "&$baseid.purp." . $entity->getAttribute('type') . "." . $name; |
| 221 |
} |
| 222 |
|
| 223 |
sub notationRefpurpose { |
| 224 |
my $count = shift; |
| 225 |
my $name = $notations[$count]; |
| 226 |
|
| 227 |
return "&$baseid.purp.notn.$name;"; |
| 228 |
} |
| 229 |
|
| 230 |
sub elementDescription { |
| 231 |
my $count = shift; |
| 232 |
my $name = $elements[$count]; |
| 233 |
my $desc = "$descdir/$name.sgm"; |
| 234 |
local $_; |
| 235 |
|
| 236 |
# return "&" . "desc.elem.$name;"; |
| 237 |
|
| 238 |
open (F, $desc); |
| 239 |
read (F, $_, -s $desc); |
| 240 |
close (F); |
| 241 |
|
| 242 |
return "\n" . $_; |
| 243 |
} |
| 244 |
|
| 245 |
sub entityDescription { |
| 246 |
my $count = shift; |
| 247 |
|
| 248 |
return "<para>desc</para>\n"; |
| 249 |
} |
| 250 |
|
| 251 |
sub notationDescription { |
| 252 |
my $count = shift; |
| 253 |
|
| 254 |
return "<para>desc</para>\n"; |
| 255 |
} |
| 256 |
|
| 257 |
# ====================================================================== |
| 258 |
|
| 259 |
sub basenames { |
| 260 |
my @names = @_; |
| 261 |
my %basename = (); |
| 262 |
my %usedname = (); |
| 263 |
|
| 264 |
foreach my $name (@names) { |
| 265 |
my $count = 2; |
| 266 |
my $bname = lc($name); |
| 267 |
|
| 268 |
if ($usedname{$bname}) { |
| 269 |
$bname = lc($name) . $count; |
| 270 |
while ($usedname{$bname}) { |
| 271 |
$bname++; |
| 272 |
} |
| 273 |
} |
| 274 |
|
| 275 |
$basename{$name} = $bname; |
| 276 |
$usedname{$name} = 1; |
| 277 |
} |
| 278 |
|
| 279 |
return %basename; |
| 280 |
} |
| 281 |
|
| 282 |
# ====================================================================== |
| 283 |
|
| 284 |
sub formatElement { |
| 285 |
my $count = shift; |
| 286 |
my $html = ""; |
| 287 |
|
| 288 |
my $name = $elements[$count]; |
| 289 |
my $element = $elements{$name}; |
| 290 |
|
| 291 |
my $cmex = undef; |
| 292 |
my $cmunx = undef; |
| 293 |
my $incl = undef; |
| 294 |
my $excl = undef; |
| 295 |
|
| 296 |
my $node = $element->getFirstChild(); |
| 297 |
while ($node) { |
| 298 |
if ($node->getNodeType() == XML::DOM::ELEMENT_NODE) { |
| 299 |
$cmex = $node if $node->getTagName() eq 'content-model-expanded'; |
| 300 |
$cmunx = $node if $node->getTagName() eq 'content-model'; |
| 301 |
$incl = $node if $node->getTagName() eq 'inclusions'; |
| 302 |
$excl = $node if $node->getTagName() eq 'exclusions'; |
| 303 |
} |
| 304 |
$node = $node->getNextSibling(); |
| 305 |
} |
| 306 |
|
| 307 |
$html .= &formatElementHeader($count); |
| 308 |
|
| 309 |
$html .= &formatElementTitle($count); |
| 310 |
|
| 311 |
if ($option{'synopsis'}) { |
| 312 |
if ($expanded eq 'expanded') { |
| 313 |
$html .= &formatElementSynopsis($count, $cmex, $cmex, $incl, $excl); |
| 314 |
} else { |
| 315 |
$html .= &formatElementSynopsis($count, $cmunx, $cmex, $incl, $excl); |
| 316 |
} |
| 317 |
} |
| 318 |
|
| 319 |
$html .= &formatElementDescription($count) if $option{'description'}; |
| 320 |
|
| 321 |
$html .= &formatElementAttrDescription($count) if $option{'attributes'}; |
| 322 |
|
| 323 |
$html .= &formatElementSeeAlso($count) if $option{'seealso'}; |
| 324 |
|
| 325 |
$html .= &formatElementExample($count) if $option{'examples'}; |
| 326 |
|
| 327 |
$html .= &formatElementFooter($count); |
| 328 |
} |
| 329 |
|
| 330 |
sub formatElementHeader { |
| 331 |
my $count = shift; |
| 332 |
my $html = ""; |
| 333 |
my $name = $elements[$count]; |
| 334 |
my $element = $elements{$name}; |
| 335 |
|
| 336 |
my $pub = "-//OASIS//DTD DocBook XML V4.2//EN"; |
| 337 |
my $sys = "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"; |
| 338 |
|
| 339 |
my $dir = $option{'base-dir'} . "/elements/$name"; |
| 340 |
if (! -d $dir) { |
| 341 |
mkdir($dir, 0755); |
| 342 |
} |
| 343 |
|
| 344 |
my $filename = "reference.e.xml"; |
| 345 |
|
| 346 |
my $rpub = "-//O'Reilly//ENTITIES DocBook RefPurposes V2.0//EN"; |
| 347 |
my $rsys = "../../../entities/refpurps.ent"; |
| 348 |
|
| 349 |
$html = ""; |
| 350 |
$html .= "<!DOCTYPE reference PUBLIC \"$pub\"\n"; |
| 351 |
$html .= " \"$sys\" [\n"; |
| 352 |
$html .= "<!ENTITY % refpurps.ent PUBLIC \"$rpub\" \"$rsys\">\n"; |
| 353 |
$html .= "%refpurps.ent;\n"; |
| 354 |
$html .= "<!ENTITY % entities.ent SYSTEM \"entities.e.ent\">\n"; |
| 355 |
$html .= "%entities.ent;\n"; |
| 356 |
$html .= "<!ENTITY refentry.xml SYSTEM \"refentry.xml\">\n"; |
| 357 |
$html .= "]>\n"; |
| 358 |
$html .= "<reference><title>$name Refentry</title>\n"; |
| 359 |
$html .= "&refentry.xml;\n"; |
| 360 |
$html .= "</reference>\n"; |
| 361 |
|
| 362 |
if (! -f "$dir/$filename") { |
| 363 |
open (F, ">$dir/$filename"); |
| 364 |
print F $html; |
| 365 |
close (F); |
| 366 |
} |
| 367 |
|
| 368 |
$filename = "reference.u.xml"; |
| 369 |
|
| 370 |
$html = ""; |
| 371 |
$html .= "<!DOCTYPE reference PUBLIC \"$pub\"\n"; |
| 372 |
$html .= " \"$sys\" [\n"; |
| 373 |
$html .= "<!ENTITY % refpurps.ent PUBLIC \"$rpub\" \"$rsys\">\n"; |
| 374 |
$html .= "%refpurps.ent;\n"; |
| 375 |
$html .= "<!ENTITY % entities.ent SYSTEM \"entities.u.ent\">\n"; |
| 376 |
$html .= "%entities.ent;\n"; |
| 377 |
$html .= "<!ENTITY refentry.xml SYSTEM \"refentry.xml\">\n"; |
| 378 |
$html .= "]>\n"; |
| 379 |
$html .= "<reference><title>$name Refentry</title>\n"; |
| 380 |
$html .= "&refentry.xml;\n"; |
| 381 |
$html .= "</reference>\n"; |
| 382 |
|
| 383 |
if (! -f "$dir/$filename") { |
| 384 |
open (F, ">$dir/$filename"); |
| 385 |
print F $html; |
| 386 |
close (F); |
| 387 |
} |
| 388 |
|
| 389 |
$html = ""; |
| 390 |
$html .= "<refentry id=\"$name.element\""; |
| 391 |
$html .= " revision='" . $revision{$name} . "'" if $revision{$name}; |
| 392 |
$html .= ">\n"; |
| 393 |
$html .= "<?dbhtml filename=\"$name.html\"?>\n\n"; |
| 394 |
|
| 395 |
return $html; |
| 396 |
} |
| 397 |
|
| 398 |
sub formatElementTitle { |
| 399 |
my $count = shift; |
| 400 |
my $name = $elements[$count]; |
| 401 |
my $element = $elements{$name}; |
| 402 |
my $html = ""; |
| 403 |
|
| 404 |
$html .= "<refmeta>\n"; |
| 405 |
$html .= "<indexterm><primary>elements</primary>\n"; |
| 406 |
$html .= "<secondary>" . $element->getAttribute('name') . "</secondary></indexterm>\n"; |
| 407 |
|
| 408 |
$html .= "<refentrytitle>"; |
| 409 |
$html .= $element->getAttribute('name'); |
| 410 |
$html .= "</refentrytitle>\n"; |
| 411 |
$html .= "<refmiscinfo>Element</refmiscinfo>\n"; |
| 412 |
$html .= "</refmeta>\n"; |
| 413 |
|
| 414 |
$html .= "<refnamediv>\n"; |
| 415 |
$html .= "<refname>" . $element->getAttribute('name') . "</refname>\n"; |
| 416 |
$html .= "<refpurpose>"; |
| 417 |
$html .= &elementRefpurpose($count); |
| 418 |
$html .= "</refpurpose>\n"; |
| 419 |
$html .= "</refnamediv>\n\n"; |
| 420 |
|
| 421 |
return $html; |
| 422 |
} |
| 423 |
|
| 424 |
sub formatElementSynopsis { |
| 425 |
my $count = shift; |
| 426 |
my $name = $elements[$count]; |
| 427 |
my $element = $elements{$name}; |
| 428 |
my $cm = shift; |
| 429 |
my $cmex = shift; |
| 430 |
my $incl = shift; |
| 431 |
my $excl = shift; |
| 432 |
my $html = ""; |
| 433 |
|
| 434 |
# What are the possibilities: mixed content, element content, or |
| 435 |
# declared content... |
| 436 |
my $mixed = $element->getAttribute('content-type') eq 'mixed'; |
| 437 |
my $declared = (!$mixed && |
| 438 |
$element->getAttribute('content-type') ne 'element'); |
| 439 |
|
| 440 |
$html .= "<refsynopsisdiv><title>Synopsis</title>\n"; |
| 441 |
$html .= "<informaltable frame='all' role='elemsynop'>\n"; |
| 442 |
$html .= "<tgroup cols='3'>\n"; |
| 443 |
$html .= "<colspec colnum='1' colname='c1'/>\n"; |
| 444 |
$html .= "<colspec colnum='2' colname='c2'/>\n"; |
| 445 |
$html .= "<colspec colnum='3' colname='c3'/>\n"; |
| 446 |
$html .= "<tbody>\n"; |
| 447 |
|
| 448 |
$html .= "<row condition='ref.synopsis' rowsep='0' role='cmtitle'>\n"; |
| 449 |
$html .= "<entry namest='c1' nameend='c3' align='left'\n"; |
| 450 |
$html .= "><emphasis role='bold'>"; |
| 451 |
|
| 452 |
if ($mixed) { |
| 453 |
$html .= "Mixed Content Model"; |
| 454 |
} elsif ($declared) { |
| 455 |
$html .= "Declared Content"; |
| 456 |
} else { |
| 457 |
$html .= "Content Model"; |
| 458 |
} |
| 459 |
|
| 460 |
$html .= "</emphasis></entry>\n"; |
| 461 |
$html .= "</row>\n"; |
| 462 |
|
| 463 |
$html .= "<row condition='ref.synopsis' rowsep='1' role='cmsynop'>\n"; |
| 464 |
$html .= "<entry namest='c1' nameend='c3' align='left'\n"; |
| 465 |
$html .= "><synopsis>"; |
| 466 |
$html .= $element->getAttribute('name') . " ::=\n"; |
| 467 |
$html .= &formatContentModel($count, $cm); |
| 468 |
|
| 469 |
$html .= "</synopsis></entry>\n"; |
| 470 |
$html .= "</row>\n"; |
| 471 |
|
| 472 |
$html .= &formatInclusions($count, $incl) |
| 473 |
if $incl && $option{'inclusions'}; |
| 474 |
|
| 475 |
$html .= &formatExclusions($count, $excl) |
| 476 |
if $excl && $option{'exclusions'}; |
| 477 |
|
| 478 |
$html .= &formatAttributeList($count) if $option{'attributes'}; |
| 479 |
|
| 480 |
$html .= &formatTagMinimization($count) if $option{'tag-minimization'}; |
| 481 |
|
| 482 |
$html .= &formatElementAppearsIn($count) if $option{'appears-in'}; |
| 483 |
|
| 484 |
$html .= "</tbody>\n"; |
| 485 |
$html .= "</tgroup>\n"; |
| 486 |
$html .= "</informaltable>\n"; |
| 487 |
$html .= "</refsynopsisdiv>\n"; |
| 488 |
|
| 489 |
my $dir = $option{'base-dir'} . "/elements/$name"; |
| 490 |
if (! -d $dir) { |
| 491 |
mkdir($dir, 0755); |
| 492 |
} |
| 493 |
|
| 494 |
my $filename = "synopsis"; |
| 495 |
if ($expanded eq 'expanded') { |
| 496 |
$filename .= ".e"; |
| 497 |
} else { |
| 498 |
$filename .= ".u"; |
| 499 |
} |
| 500 |
|
| 501 |
open (SYNOP, ">$dir/$prefix$filename.gen") |
| 502 |
|| die "Can't open: $dir/$prefix$filename.gen: $!"; |
| 503 |
print SYNOP $html; |
| 504 |
close (SYNOP); |
| 505 |
|
| 506 |
$html = "&$name.synopsis.gen;\n"; |
| 507 |
|
| 508 |
return $html; |
| 509 |
} |
| 510 |
|
| 511 |
sub formatInclusions { |
| 512 |
my $count = shift; |
| 513 |
my $cm = shift; |
| 514 |
my $name = $elements[$count]; |
| 515 |
my $element = $elements{$name}; |
| 516 |
my $html = ""; |
| 517 |
|
| 518 |
# $html .= "<![ %" . "$baseid.ms.elem.inclusions; [\n"; |
| 519 |
$html .= "<row condition='ref.inclusions' rowsep='0' role='incltitle'>\n"; |
| 520 |
$html .= "<entry namest='c1' nameend='c3' align='left'\n"; |
| 521 |
$html .= "><emphasis role='bold'>Inclusions</emphasis></entry>\n"; |
| 522 |
$html .= "</row>\n"; |
| 523 |
|
| 524 |
$html .= "<row condition='ref.inclusions' rowsep='1' role='inclsynop'>\n"; |
| 525 |
$html .= "<entry namest='c1' nameend='c3' align='left'\n"; |
| 526 |
$html .= "><synopsis>"; |
| 527 |
$html .= &formatContentModel($count, $cm); |
| 528 |
$html .= "</synopsis></entry>\n"; |
| 529 |
$html .= "</row>\n"; |
| 530 |
# $html .= "]]>\n"; |
| 531 |
|
| 532 |
return $html; |
| 533 |
} |
| 534 |
|
| 535 |
sub formatExclusions { |
| 536 |
my $count = shift; |
| 537 |
my $cm = shift; |
| 538 |
my $name = $elements[$count]; |
| 539 |
my $element = $elements{$name}; |
| 540 |
my $html = ""; |
| 541 |
|
| 542 |
# $html .= "<![ %" . "$baseid.ms.elem.exclusions; [\n"; |
| 543 |
$html .= "<row condition='ref.exclusions' rowsep='0' role='excltitle'>\n"; |
| 544 |
$html .= "<entry namest='c1' nameend='c3' align='left'\n"; |
| 545 |
$html .= "><emphasis role='bold'>Exclusions</emphasis></entry>\n"; |
| 546 |
$html .= "</row>\n"; |
| 547 |
|
| 548 |
$html .= "<row condition='ref.exclusions' rowsep='1' role='exclsynop'>\n"; |
| 549 |
$html .= "<entry namest='c1' nameend='c3' align='left'\n"; |
| 550 |
$html .= "><synopsis>"; |
| 551 |
$html .= &formatContentModel($count, $cm); |
| 552 |
$html .= "</synopsis></entry>\n"; |
| 553 |
$html .= "</row>\n"; |
| 554 |
# $html .= "]]>\n"; |
| 555 |
|
| 556 |
return $html; |
| 557 |
} |
| 558 |
|
| 559 |
sub formatAttributeList { |
| 560 |
my $count = shift; |
| 561 |
my $html = ""; |
| 562 |
my $name = $elements[$count]; |
| 563 |
my $element = $elements{$name}; |
| 564 |
my $attlist = $attlists{$name}; |
| 565 |
my %attrs = (); |
| 566 |
my %cmnatt = (); |
| 567 |
my $common = 1; |
| 568 |
my $uncommon = 0; |
| 569 |
|
| 570 |
# Check for DocBook common attributes |
| 571 |
|
| 572 |
foreach my $attr (@common_attributes) { |
| 573 |
$cmnatt{$attr} = 0; |
| 574 |
# print "Common: $attr\n"; |
| 575 |
} |
| 576 |
|
| 577 |
if (defined($attlist)) { |
| 578 |
my $attelem = $attlist->getElementsByTagName("attribute"); |
| 579 |
|
| 580 |
for (my $count = 0; $count < $attelem->getLength(); $count++) { |
| 581 |
my $attr = $attelem->item($count); |
| 582 |
my $name = $attr->getAttribute('name'); |
| 583 |
# print "Attr: $name\n"; |
| 584 |
$attrs{$name} = 1; |
| 585 |
if (exists $cmnatt{lc($name)}) { |
| 586 |
$cmnatt{lc($name)} = 1; |
| 587 |
} else { |
| 588 |
$uncommon = 1; |
| 589 |
} |
| 590 |
} |
| 591 |
|
| 592 |
foreach my $attr (keys %cmnatt) { |
| 593 |
if ($cmnatt{$attr} == 0) { |
| 594 |
# print "not common: $attr\n"; |
| 595 |
$common = 0; |
| 596 |
} |
| 597 |
} |
| 598 |
|
| 599 |
# print "Common? $common\n"; |
| 600 |
|
| 601 |
if ($common) { |
| 602 |
foreach my $attr (keys %attrs) { |
| 603 |
if (exists $cmnatt{lc($attr)}) { |
| 604 |
# print "Del: $attr\n"; |
| 605 |
delete $attrs{$attr}; |
| 606 |
} else { |
| 607 |
# print "Keep: $attr\n"; |
| 608 |
} |
| 609 |
} |
| 610 |
} |
| 611 |
} |
| 612 |
|
| 613 |
# $html .= "<![ %" . "$baseid.ms.elem.refsynopsisdiv.attr; [\n"; |
| 614 |
|
| 615 |
my $rowsep = "1"; |
| 616 |
$rowsep = "0" if defined($attlist) && ($uncommon || !$common); |
| 617 |
|
| 618 |
$html .= "<row condition='ref.rsdiv.attr' rowsep='$rowsep' role='attrtitle'>\n"; |
| 619 |
$html .= "<entry colsep='0'\n"; |
| 620 |
$html .= "><emphasis role='bold'>Attributes</emphasis></entry>\n"; |
| 621 |
|
| 622 |
if (!defined($attlist)) { |
| 623 |
$html .= "<entry namest='c2' nameend='c3'>"; |
| 624 |
$html .= "None"; |
| 625 |
$html .= "</entry>\n"; |
| 626 |
} elsif ($common) { |
| 627 |
$html .= "<entry namest='c2' nameend='c3'>"; |
| 628 |
# $html .= "<phrase role=\"common.attributes\">"; |
| 629 |
# $html .= "Common attributes"; |
| 630 |
# $html .= "</phrase>"; |
| 631 |
$html .= "<link linkend=\"common.attributes\">Common attributes</link>"; |
| 632 |
$html .= "</entry>\n"; |
| 633 |
} else { |
| 634 |
$html .= "<entry namest='c2' nameend='c3'></entry>\n"; |
| 635 |
} |
| 636 |
|
| 637 |
$html .= "</row>\n"; |
| 638 |
|
| 639 |
if (defined($attlist) && ($uncommon || !$common)) { |
| 640 |
$html .= "<row condition='ref.rsdiv.attr' rowsep='1' role='attrheader'>\n"; |
| 641 |
$html .= "<entry role='th'><para\n"; |
| 642 |
$html .= "><emphasis role='bold'>Name</emphasis></para></entry>\n"; |
| 643 |
$html .= "<entry role='th'><para\n"; |
| 644 |
$html .= "><emphasis role='bold'>Type</emphasis></para></entry>\n"; |
| 645 |
$html .= "<entry role='th'><para\n"; |
| 646 |
$html .= "><emphasis role='bold'>Default</emphasis></para></entry>\n"; |
| 647 |
$html .= "</row>\n"; |
| 648 |
$html .= &formatAttributes($attlist, 'ref.rsdiv.attr', %attrs); |
| 649 |
} |
| 650 |
|
| 651 |
# $html .= "]]>\n\n"; |
| 652 |
|
| 653 |
return $html; |
| 654 |
} |
| 655 |
|
| 656 |
sub formatAttributes { |
| 657 |
my $attlist = shift; |
| 658 |
my $condition = shift; |
| 659 |
my %atthash = @_; |
| 660 |
my $html = ""; |
| 661 |
my $attrs = $attlist->getElementsByTagName("attribute"); |
| 662 |
my $last = ""; |
| 663 |
|
| 664 |
# figure out the last; have to do it this way because we may |
| 665 |
# skip some attributes, possibly the one that's last in the |
| 666 |
# actual list. |
| 667 |
for (my $count = 0; $count < $attrs->getLength(); $count++) { |
| 668 |
my $attr = $attrs->item($count); |
| 669 |
my $name = $attr->getAttribute('name'); |
| 670 |
next if !exists $atthash{$name}; |
| 671 |
$last = $name; |
| 672 |
} |
| 673 |
|
| 674 |
for (my $count = 0; $count < $attrs->getLength(); $count++) { |
| 675 |
my $attr = $attrs->item($count); |
| 676 |
|
| 677 |
my $name = $attr->getAttribute('name'); |
| 678 |
my $type = $attr->getAttribute('value'); |
| 679 |
my $decltype = $attr->getAttribute('type'); |
| 680 |
my $default = ""; |
| 681 |
|
| 682 |
next if !exists $atthash{$name}; |
| 683 |
|
| 684 |
if ($decltype eq '#IMPLIED') { |
| 685 |
$default = "<emphasis>None</emphasis>"; |
| 686 |
} elsif ($decltype eq '#REQUIRED') { |
| 687 |
$default = "<emphasis>Required</emphasis>"; |
| 688 |
} elsif ($decltype eq '#CONREF') { |
| 689 |
$default = "<emphasis>Content reference</emphasis>"; |
| 690 |
} else { |
| 691 |
$default = $attr->getAttribute('default'); |
| 692 |
if ($default =~ /\"/) { |
| 693 |
$default = "'" . $default . "'"; |
| 694 |
} else { |
| 695 |
$default = "\"" . $default . "\""; |
| 696 |
} |
| 697 |
} |
| 698 |
|
| 699 |
if ($decltype eq '#FIXED') { |
| 700 |
$default = $default . " <emphasis>(fixed)</emphasis>"; |
| 701 |
} |
| 702 |
|
| 703 |
if ($name eq $last) { |
| 704 |
$html .= "<row condition='$condition' rowsep=\"1\" role=\"attr\">\n"; |
| 705 |
} else { |
| 706 |
$html .= "<row condition='$condition' role=\"attr\">\n"; |
| 707 |
} |
| 708 |
|
| 709 |
$html .= &formatCell($name); |
| 710 |
$html .= &formatValues($type, $attr); |
| 711 |
$html .= &formatCell($default); |
| 712 |
$html .= "</row>\n"; |
| 713 |
} |
| 714 |
|
| 715 |
return $html; |
| 716 |
} |
| 717 |
|
| 718 |
sub formatCell { |
| 719 |
my $value = shift; |
| 720 |
|
| 721 |
return "<entry align='left' valign='top'>$value</entry>\n"; |
| 722 |
} |
| 723 |
|
| 724 |
sub formatValues { |
| 725 |
my $values = shift; |
| 726 |
my $attr = shift; |
| 727 |
my $enum = $attr->getAttribute('enumeration'); |
| 728 |
my $html = ""; |
| 729 |
|
| 730 |
if ($enum eq 'no' || $enum eq '') { |
| 731 |
return &formatCell($values); |
| 732 |
} |
| 733 |
|
| 734 |
$html .= "<entry align='left' valign='top'>"; |
| 735 |
|
| 736 |
# if ($enum eq 'notation') { |
| 737 |
# $html .= "<para><emphasis>Enumerated notation:</emphasis>\n</para>"; |
| 738 |
# } else { |
| 739 |
# $html .= "<para><emphasis>Enumeration:</emphasis>\n</para>"; |
| 740 |
# } |
| 741 |
# |
| 742 |
# $html .= "<simplelist>\n"; |
| 743 |
|
| 744 |
$html .= "<simplelist"; |
| 745 |
if ($enum eq 'notation') { |
| 746 |
$html .= " role='notationenum'"; |
| 747 |
} else { |
| 748 |
$html .= " role='enum'"; |
| 749 |
} |
| 750 |
$html .= ">\n"; |
| 751 |
|
| 752 |
foreach my $val (sort { uc($a) cmp uc($b) } |
| 753 |
split(/\s+/, $attr->getAttribute('value'))) { |
| 754 |
$html .= "<member>$val</member>\n"; |
| 755 |
} |
| 756 |
$html .= "</simplelist></entry>\n"; |
| 757 |
|
| 758 |
return $html; |
| 759 |
} |
| 760 |
|
| 761 |
sub formatTagMinimization { |
| 762 |
my $count = shift; |
| 763 |
my $name = $elements[$count]; |
| 764 |
my $element = $elements{$name}; |
| 765 |
my $html = ""; |
| 766 |
my $stagm = $element->getAttribute('stagm') || "-"; |
| 767 |
my $etagm = $element->getAttribute('etagm') || "-"; |
| 768 |
|
| 769 |
if ($element->getAttribute('stagm') |
| 770 |
|| $element->getAttribute('etagm')) { |
| 771 |
my (%min) = ('--' => "Both the start- and end-tags are required for this element.", |
| 772 |
'OO' => "Both the start- and end-tags are optional for this element, if your SGML declaration allows tag minimization.", |
| 773 |
'O-' => "The start-tag is optional for this element, if your SGML declaration allows tag minimization. The end-tag is required.", |
| 774 |
'-O' => "The start-tag is required for this element. The end-tag is optional, if your SGML declaration allows minimization." |
| 775 |
); |
| 776 |
|
| 777 |
# $html .= "<![ %" . "$baseid.ms.elem.refsynopsisdiv.tagmin; [\n"; |
| 778 |
$html .= "<row condition='ref.rsdiv.tagmin' rowsep='0' role='tmtitle'>\n"; |
| 779 |
$html .= "<entry namest='c1' nameend='c3' align='left'\n"; |
| 780 |
$html .= "><emphasis role='bold'>Tag Minimization</emphasis>"; |
| 781 |
$html .= "</entry>\n"; |
| 782 |
$html .= "</row>\n"; |
| 783 |
|
| 784 |
$html .= "<row condition='ref.rsdiv.tagmin' rowsep='1' role='tmsynop'>\n"; |
| 785 |
$html .= "<entry namest='c1' nameend='c3' align='left'\n"; |
| 786 |
$html .= "><para>"; |
| 787 |
$html .= $min{$stagm . $etagm}; |
| 788 |
$html .= "</para></entry>\n"; |
| 789 |
$html .= "</row>\n"; |
| 790 |
# $html .= "]]>\n\n"; |
| 791 |
} |
| 792 |
|
| 793 |
return $html; |
| 794 |
} |
| 795 |
|
| 796 |
sub formatElementAppearsIn { |
| 797 |
my $count = shift; |
| 798 |
my $html = ""; |
| 799 |
my $elementname = $elements[$count]; |
| 800 |
my $element = $elements{$elementname}; |
| 801 |
my %appears = (); |
| 802 |
|
| 803 |
%appears = %{$APPEARSIN{$elementname}} if exists $APPEARSIN{$elementname}; |
| 804 |
|
| 805 |
if (%appears) { |
| 806 |
my @ents = sort { uc($a) cmp uc($b) } keys %appears; |
| 807 |
|
| 808 |
# $html .= "<![ %" . "$baseid.ms.elem.refsynopsisdiv.pe; [\n"; |
| 809 |
$html .= "<row condition='ref.rsdiv.pe' rowsep='0' role='petitle'>\n"; |
| 810 |
$html .= "<entry namest='c1' nameend='c3' align='left'\n"; |
| 811 |
$html .= "><emphasis role='bold'>Parameter Entities</emphasis>"; |
| 812 |
$html .= "</entry>\n"; |
| 813 |
$html .= "</row>\n"; |
| 814 |
|
| 815 |
while (@ents) { |
| 816 |
$html .= "<row condition='ref.rsdiv.pe' rowsep='0' role='pe'>\n"; |
| 817 |
|
| 818 |
for (my $count = 0; $count < 3; $count++) { |
| 819 |
my $name = shift @ents; |
| 820 |
if ($name) { |
| 821 |
my $entity = $entities{$name}; |
| 822 |
$html .= "<entry colsep='0'>"; |
| 823 |
$html .= "<sgmltag class='paramentity'>"; |
| 824 |
$html .= $entity->getAttribute('name'); |
| 825 |
$html .= "</sgmltag>"; |
| 826 |
$html .= "</entry>\n"; |
| 827 |
} else { |
| 828 |
$html .= "<entry colsep='0'></entry>\n"; |
| 829 |
} |
| 830 |
} |
| 831 |
|
| 832 |
$html .= "</row>\n"; |
| 833 |
} |
| 834 |
|
| 835 |
# $html .= "]]>\n"; |
| 836 |
} |
| 837 |
|
| 838 |
return $html; |
| 839 |
} |
| 840 |
|
| 841 |
sub formatElementDescription { |
| 842 |
my $count = shift; |
| 843 |
my $name = $elements[$count]; |
| 844 |
my $element = $elements{$name}; |
| 845 |
my $desc = &elementDescription($count); |
| 846 |
my $html = ""; |
| 847 |
|
| 848 |
$html = "<refsect1 condition='ref.description'><title>Description</title> |
| 849 |
|
| 850 |
<para></para> |
| 851 |
|
| 852 |
<refsect2><title>Processing expectations</title> |
| 853 |
<para></para> |
| 854 |
</refsect2>\n\n"; |
| 855 |
|
| 856 |
$html .= &formatParents($count); |
| 857 |
$html .= &formatChildren($count); |
| 858 |
|
| 859 |
$html .= "\n</refsect1>\n\n"; |
| 860 |
|
| 861 |
return $html; |
| 862 |
} |
| 863 |
|
| 864 |
sub formatParents { |
| 865 |
my $count = shift; |
| 866 |
my $name = $elements[$count]; |
| 867 |
my $element = $elements{$name}; |
| 868 |
my $html = ""; |
| 869 |
|
| 870 |
if (exists $PARENTS{$name}) { |
| 871 |
$html .= "<refsect2 condition='ref.desc.parents'><title>Parents</title>\n"; |
| 872 |
$html .= "<para>These elements contain "; |
| 873 |
$html .= $element->getAttribute('name') . ":\n"; |
| 874 |
$html .= "<simplelist type='inline'>"; |
| 875 |
|
| 876 |
my $pname; |
| 877 |
foreach $pname (sort { uc($a) cmp uc($b) } keys %{$PARENTS{$name}}) { |
| 878 |
my $child = $elements{$pname}; |
| 879 |
$html .= "<member>"; |
| 880 |
# $html .= "<link linkend=\"$baseid.elem.$pname\">"; |
| 881 |
$html .= "<sgmltag>" . $child->getAttribute('name') . "</sgmltag>"; |
| 882 |
# $html .= "</link>"; |
| 883 |
$html .= "</member>\n"; |
| 884 |
} |
| 885 |
|
| 886 |
$html .= "</simplelist>.</para>\n"; |
| 887 |
$html .= "</refsect2>\n"; |
| 888 |
|
| 889 |
my $dir = $option{'base-dir'} . "/elements/$name"; |
| 890 |
if (! -d $dir) { |
| 891 |
mkdir($dir, 0755); |
| 892 |
} |
| 893 |
|
| 894 |
my $filename = "parents"; |
| 895 |
if ($expanded eq 'expanded') { |
| 896 |
open (PAR, ">$dir/$prefix$filename.gen") |
| 897 |
|| die "Can't open: $dir/$prefix$filename.gen: $!"; |
| 898 |
print PAR $html; |
| 899 |
close (PAR); |
| 900 |
} else { |
| 901 |
# unexpanded is exactly the same |
| 902 |
} |
| 903 |
|
| 904 |
$html = "&$name.parents.gen;\n"; |
| 905 |
} |
| 906 |
|
| 907 |
return $html; |
| 908 |
} |
| 909 |
|
| 910 |
sub formatChildren { |
| 911 |
my $count = shift; |
| 912 |
my $name = $elements[$count]; |
| 913 |
my $element = $elements{$name}; |
| 914 |
my $html = ""; |
| 915 |
my $mixed = $element->getAttribute('content-type') eq 'mixed'; |
| 916 |
my $declared = (!$mixed && |
| 917 |
$element->getAttribute('content-type') ne 'element'); |
| 918 |
|
| 919 |
return "" if $declared; # can't be any children... |
| 920 |
|
| 921 |
if (exists $CHILDREN{$name} |
| 922 |
|| exists $POSSINCL{$name} |
| 923 |
|| exists $POSSEXCL{$name}) { |
| 924 |
$html .= "<refsect2 condition='ref.desc.children'><title>Children</title>\n"; |
| 925 |
} |
| 926 |
|
| 927 |
if (exists $CHILDREN{$name}) { |
| 928 |
$html .= "<para>The following elements occur in "; |
| 929 |
$html .= $element->getAttribute('name') . ":\n"; |
| 930 |
$html .= "<simplelist type='inline'>"; |
| 931 |
|
| 932 |
my $cname; |
| 933 |
foreach $cname (sort { uc($a) cmp uc($b) } keys %{$CHILDREN{$name}}) { |
| 934 |
my $child = $elements{$cname}; |
| 935 |
|
| 936 |
die "Unexpected error (1): can't find element \"$cname\".\n" |
| 937 |
if !$child; |
| 938 |
|
| 939 |
$html .= "<member>"; |
| 940 |
# $html .= "<link linkend=\"$baseid.elem.$cname\">"; |
| 941 |
$html .= "<sgmltag>"; |
| 942 |
$html .= $child->getAttribute('name'); |
| 943 |
$html .= "</sgmltag>"; |
| 944 |
# $html .= "</link>"; |
| 945 |
$html .= "</member>\n"; |
| 946 |
} |
| 947 |
|
| 948 |
$html .= "</simplelist>.</para>\n"; |
| 949 |
} |
| 950 |
|
| 951 |
if (exists $POSSINCL{$name}) { |
| 952 |
$html .= "<para>In some contexts, the following elements are\n"; |
| 953 |
$html .= "allowed anywhere:\n"; |
| 954 |
$html .= "<simplelist type='inline'>\n"; |
| 955 |
|
| 956 |
my $cname; |
| 957 |
foreach $cname (sort { uc($a) cmp uc($b) } keys %{$POSSINCL{$name}}) { |
| 958 |
my $child = $elements{$cname}; |
| 959 |
|
| 960 |
die "Unexpected error (2): can't find element \"$cname\".\n" |
| 961 |
if !$child; |
| 962 |
|
| 963 |
$html .= "<member>"; |
| 964 |
# $html .= "<link linkend=\"$baseid.elem.$cname\">"; |
| 965 |
$html .= "<sgmltag>"; |
| 966 |
$html .= $child->getAttribute('name'); |
| 967 |
$html .= "</sgmltag>"; |
| 968 |
# $html .= "</link>"; |
| 969 |
$html .= "</member>\n"; |
| 970 |
} |
| 971 |
|
| 972 |
$html .= "</simplelist>.</para>\n\n"; |
| 973 |
} |
| 974 |
|
| 975 |
if (exists $POSSEXCL{$name}) { |
| 976 |
$html .= "<para>In some contexts, the following elements are\n"; |
| 977 |
$html .= "excluded:\n"; |
| 978 |
$html .= "<simplelist type='inline'>\n"; |
| 979 |
|
| 980 |
my $cname; |
| 981 |
foreach $cname (sort { uc($a) cmp uc($b) } keys %{$POSSEXCL{$name}}) { |
| 982 |
my $element = $elements{$cname}; |
| 983 |
$html .= "<member>"; |
| 984 |
# $html .= "<link linkend=\"$baseid.elem.$cname\">"; |
| 985 |
$html .= "<sgmltag>"; |
| 986 |
$html .= $element->getAttribute('name'); |
| 987 |
$html .= "</sgmltag>"; |
| 988 |
# $html .= "</link>"; |
| 989 |
$html .= "</member>\n"; |
| 990 |
} |
| 991 |
|
| 992 |
$html .= "</simplelist>.</para>\n\n"; |
| 993 |
} |
| 994 |
|
| 995 |
if (exists $CHILDREN{$name} |
| 996 |
|| exists $POSSINCL{$name} |
| 997 |
|| exists $POSSEXCL{$name}) { |
| 998 |
$html .= "</refsect2>\n"; |
| 999 |
|
| 1000 |
my $dir = $option{'base-dir'} . "/elements/$name"; |
| 1001 |
if (! -d $dir) { |
| 1002 |
mkdir($dir, 0755); |
| 1003 |
} |
| 1004 |
|
| 1005 |
my $filename = "children"; |
| 1006 |
if ($expanded eq 'expanded') { |
| 1007 |
open (CHD, ">$dir/$prefix$filename.gen") |
| 1008 |
|| die "Can't open: $dir/$prefix$filename.gen: $!"; |
| 1009 |
print CHD $html; |
| 1010 |
close (CHD); |
| 1011 |
} else { |
| 1012 |
# unexpanded is exactly the same |
| 1013 |
} |
| 1014 |
|
| 1015 |
$html = "&$name.children.gen;\n"; |
| 1016 |
} |
| 1017 |
|
| 1018 |
return $html; |
| 1019 |
} |
| 1020 |
|
| 1021 |
sub formatElementAttrDescription { |
| 1022 |
my $count = shift; |
| 1023 |
my $name = $elements[$count]; |
| 1024 |
my $html = ""; |
| 1025 |
my $attlist = $attlists{$name}; |
| 1026 |
my %attrs = (); |
| 1027 |
my %cmnatt = ('id' => 0, |
| 1028 |
'role' => 0, |
| 1029 |
'lang' => 0, |
| 1030 |
'remap'=> 0, |
| 1031 |
'xreflabel' => 0, |
| 1032 |
'revisionflag' => 0, |
| 1033 |
'arch' => 0, |
| 1034 |
'conformance' => 0, |
| 1035 |
'os' => 0, |
| 1036 |
'revision' => 0, |
| 1037 |
'userlevel' => 0, |
| 1038 |
'vendor' => 0, |
| 1039 |
'security' => 0, |
| 1040 |
'condition' => 0); |
| 1041 |
|
| 1042 |
# Check for DocBook common attributes |
| 1043 |
|
| 1044 |
if (defined($attlist)) { |
| 1045 |
my $attelem = $attlist->getElementsByTagName("attribute"); |
| 1046 |
|
| 1047 |
for (my $count = 0; $count < $attelem->getLength(); $count++) { |
| 1048 |
my $attr = $attelem->item($count); |
| 1049 |
my $name = $attr->getAttribute('name'); |
| 1050 |
$attrs{$name} = 1 if !defined($cmnatt{lc($name)}); |
| 1051 |
} |
| 1052 |
} |
| 1053 |
|
| 1054 |
return $html if !%attrs; |
| 1055 |
|
| 1056 |
$html .= "<refsect1 condition='ref.elem.attrdesc'><title>Attributes</title>\n"; |
| 1057 |
|
| 1058 |
$html .= "<variablelist>\n"; |
| 1059 |
|
| 1060 |
foreach $attr (sort keys %attrs) { |
| 1061 |
my $desc = "attr." . lc($attr) . ".$name"; |
| 1062 |
|
| 1063 |
$html .= "<varlistentry><term>$attr</term>\n"; |
| 1064 |
$html .= "<listitem>\n"; |
| 1065 |
$html .= "&$desc;\n"; |
| 1066 |
$html .= "</listitem>\n"; |
| 1067 |
$html .= "</varlistentry>\n"; |
| 1068 |
} |
| 1069 |
|
| 1070 |
$html .= "</variablelist>\n"; |
| 1071 |
|
| 1072 |
$html .= "</refsect1>\n"; |
| 1073 |
|
| 1074 |
return $html; |
| 1075 |
} |
| 1076 |
|
| 1077 |
my %SeeAlso = (); |
| 1078 |
|
| 1079 |
sub formatElementSeeAlso { |
| 1080 |
my $count = shift; |
| 1081 |
my $name = $elements[$count]; |
| 1082 |
my @group = (); |
| 1083 |
my $html = ""; |
| 1084 |
|
| 1085 |
if (!%SeeAlso) { |
| 1086 |
my $ingroup = 0; |
| 1087 |
|
| 1088 |
open (F, "$libdir/seealso") || die "Failed to open: $libdir/seealso\n"; |
| 1089 |
while (<F>) { |
| 1090 |
chop; |
| 1091 |
if (/^\s+(\S+)/) { |
| 1092 |
push(@group, lc($1)); |
| 1093 |
$ingroup = 1; |
| 1094 |
} |
| 1095 |
|
| 1096 |
if (/^\S/ && $ingroup) { |
| 1097 |
$ingroup = 0; |
| 1098 |
foreach my $elem (@group) { |
| 1099 |
$SeeAlso{$elem} = {} if ! exists $SeeAlso{$elem}; |
| 1100 |
foreach my $grelem (@group) { |
| 1101 |
$SeeAlso{$elem}->{$grelem} = 1; |
| 1102 |
} |
| 1103 |
} |
| 1104 |
@group = (); |
| 1105 |
} |
| 1106 |
|
| 1107 |
if (/^\S/) { |
| 1108 |
$title = $_; |
| 1109 |
} |
| 1110 |
} |
| 1111 |
close (F); |
| 1112 |
} |
| 1113 |
|
| 1114 |
@group = (); |
| 1115 |
foreach my $grelem (sort keys %{$SeeAlso{$name}}) { |
| 1116 |
push (@group, $grelem) unless $name eq $grelem; |
| 1117 |
} |
| 1118 |
|
| 1119 |
if (@group) { |
| 1120 |
$html .= "<para>"; |
| 1121 |
$html .= "<simplelist type=\"inline\">\n"; |
| 1122 |
foreach my $elem (@group) { |
| 1123 |
my $element = $elements{$elem}; |
| 1124 |
$html .= "<member>"; |
| 1125 |
# $html .= "<link linkend=\"$baseid.elem.$elem\">"; |
| 1126 |
$html .= "<sgmltag>"; |
| 1127 |
|
| 1128 |
if ($element) { |
| 1129 |
$html .= $element->getAttribute('name'); |
| 1130 |
} else { |
| 1131 |
print STDERR "No element $elem in formatElementSeeAlso???\n"; |
| 1132 |
$html .= "???"; |
| 1133 |
} |
| 1134 |
|
| 1135 |
$html .= "</sgmltag>"; |
| 1136 |
# $html .= "</link>"; |
| 1137 |
$html .= "</member>\n"; |
| 1138 |
} |
| 1139 |
$html .= "</simplelist>.\n</para>\n"; |
| 1140 |
|
| 1141 |
my $dir = $option{'base-dir'} . "/elements/$name"; |
| 1142 |
if (! -d $dir) { |
| 1143 |
mkdir($dir, 0755); |
| 1144 |
} |
| 1145 |
|
| 1146 |
my $filename = "seealso"; |
| 1147 |
if ($expanded eq 'expanded') { |
| 1148 |
open (SEE, ">$dir/$prefix$filename.gen") |
| 1149 |
|| die "Can't open: $dir/$prefix$filename.gen: $!"; |
| 1150 |
print SEE $html; |
| 1151 |
close (SEE); |
| 1152 |
} else { |
| 1153 |
# unexpanded is exactly the same |
| 1154 |
} |
| 1155 |
|
| 1156 |
$html = "<refsect1 condition='ref.elem.seealso'><title>See Also</title>\n"; |
| 1157 |
$html .= "&$name.seealso.gen;\n"; |
| 1158 |
$html .= "</refsect1>\n"; |
| 1159 |
} |
| 1160 |
|
| 1161 |
return $html; |
| 1162 |
} |
| 1163 |
|
| 1164 |
sub formatElementExample { |
| 1165 |
my $count = shift; |
| 1166 |
my $name = $elements[$count]; |
| 1167 |
my $element = $elements{$name}; |
| 1168 |
my $examplehead = "<refsect1><title>Examples</title>\n\n"; |
| 1169 |
my $examplefoot = "</refsect1>\n"; |
| 1170 |
my $see = ""; |
| 1171 |
my $example = ""; |
| 1172 |
my $done = 0; |
| 1173 |
my $excount = 1; |
| 1174 |
|
| 1175 |
my %format = ( |
| 1176 |
'blockquote' => 1, |
| 1177 |
'caution' => 1, |
| 1178 |
'cmdsynopsis' => 1, |
| 1179 |
'equation' => 1, |
| 1180 |
'example' => 1, |
| 1181 |
'figure' => 1, |
| 1182 |
'formalpara' => 1, |
| 1183 |
'funcsynopsis' => 1, |
| 1184 |
'glosslist' => 1, |
| 1185 |
'important' => 1, |
| 1186 |
'informalexample' => 1, |
| 1187 |
'informalfigure' => 1, |
| 1188 |
'informaltable' => 1, |
| 1189 |
'itemizedlist' => 1, |
| 1190 |
'mediaobject' => 1, |
| 1191 |
'mediaobjectco' => 1, |
| 1192 |
'msgset' => 1, |
| 1193 |
'note' => 1, |
| 1194 |
'orderedlist' => 1, |
| 1195 |
'para' => 1, |
| 1196 |
'procedure' => 1, |
| 1197 |
'programlistingco' => 1, |
| 1198 |
'qandaset' => 1, |
| 1199 |
'screen' => 1, |
| 1200 |
'screenshot' => 1, |
| 1201 |
'segmentedlist' => 1, |
| 1202 |
'simpara' => 1, |
| 1203 |
'simplelist' => 1, |
| 1204 |
'synopsis' => 1, |
| 1205 |
'table' => 1, |
| 1206 |
'tip' => 1, |
| 1207 |
'variablelist' => 1, |
| 1208 |
'warning' => 1, |
| 1209 |
); |
| 1210 |
|
| 1211 |
local *F, $_; |
| 1212 |
|
| 1213 |
# this really just makes .txt and .gen versions of the files |
| 1214 |
|
| 1215 |
my $dir = $option{'base-dir'} . "/elements/$name"; |
| 1216 |
if (! -d $dir) { |
| 1217 |
mkdir($dir, 0755); |
| 1218 |
} |
| 1219 |
|
| 1220 |
while (!$done) { |
| 1221 |
$done = 1; |
| 1222 |
my $filename = "$dir/example.$excount"; |
| 1223 |
$file = "$filename.xml"; |
| 1224 |
|
| 1225 |
if (open (F, $file)) { |
| 1226 |
read (F, $_, -s $file); |
| 1227 |
close (F); |
| 1228 |
#$_ .= "\n" if substr($_, length($_), 1) ne "\n"; |
| 1229 |
|
| 1230 |
my $doctype = ""; |
| 1231 |
if (/(<!DOCTYPE[^>]+\[.*?\]\>\s*)(.*)$/s) { |
| 1232 |
$doctype = $1; |
| 1233 |
$_ = $2; |
| 1234 |
} elsif (/(<!DOCTYPE[^>]+>\s*)(.*)$/s) { |
| 1235 |
$doctype = $1; |
| 1236 |
$_ = $2; |
| 1237 |
} else { |
| 1238 |
warn "No doctype declaration on $filename?\n"; |
| 1239 |
} |
| 1240 |
|
| 1241 |
my $tag = $1 if /^[^<]*<([a-zA-Z0-9]+)/s; |
| 1242 |
|
| 1243 |
open (EX, ">$filename.txt") || die "Can't open: $filename.txt: $!"; |
| 1244 |
my $text = $doctype . $_; |
| 1245 |
$text =~ s/\&/\&/sg; |
| 1246 |
$text =~ s/\</\</sg; |
| 1247 |
$text =~ s/\>/\>/sg; |
| 1248 |
print EX $text; |
| 1249 |
close (EX); |
| 1250 |
|
| 1251 |
if ($format{lc($tag)}) { |
| 1252 |
open (EX,">$filename.gen") || die "Can't open: $filename.gen $!"; |
| 1253 |
print EX $_; |
| 1254 |
close (EX); |
| 1255 |
} |
| 1256 |
|
| 1257 |
$done = 0; |
| 1258 |
} |
| 1259 |
|
| 1260 |
$excount++; |
| 1261 |
} |
| 1262 |
|
| 1263 |
$excount -= 2; # yes, two. because of the way that loop works. |
| 1264 |
|
| 1265 |
my $html = ""; |
| 1266 |
|
| 1267 |
if ($excount > 0) { |
| 1268 |
$html .= "\n<refsect1 condition='ref.examples'><title>Examples</title>\n\n"; |
| 1269 |
for (my $count = 1; $count <= $excount; $count++) { |
| 1270 |
$html .= "<informalexample role='example-source'>\n"; |
| 1271 |
$html .= "<programlisting>&$name.example.$count.txt;</programlisting>\n"; |
| 1272 |
$html .= "</informalexample>\n\n"; |
| 1273 |
|
| 1274 |
$html .= "<anchor id='ex.os.$name.$count' role='HACK-ex.out.start'/>\n"; |
| 1275 |
$html .= "&$name.example.$count.gen;\n"; |
| 1276 |
$html .= "<anchor id='ex.oe.$name.$count' role='HACK-ex.out.end'/>\n\n"; |
| 1277 |
|
| 1278 |
$html .= "</refsect1>\n\n"; |
| 1279 |
} |
| 1280 |
} |
| 1281 |
|
| 1282 |
return $html; |
| 1283 |
} |
| 1284 |
|
| 1285 |
sub formatElementFooter { |
| 1286 |
my $count = shift; |
| 1287 |
my $html = ""; |
| 1288 |
|
| 1289 |
$html .= "</refentry>\n\n"; |
| 1290 |
|
| 1291 |
return $html; |
| 1292 |
} |
| 1293 |
|
| 1294 |
# ---------------------------------------------------------------------- |
| 1295 |
|
| 1296 |
my $state = 'NONE'; |
| 1297 |
my $depth = 0; |
| 1298 |
my $col = 0; |
| 1299 |
|
| 1300 |
sub formatContentModel { |
| 1301 |
my $count = shift; |
| 1302 |
my $cm = shift; |
| 1303 |
my $node = $cm->getFirstChild(); |
| 1304 |
my $html = ""; |
| 1305 |
|
| 1306 |
$state = "NONE"; |
| 1307 |
$depth = 0; |
| 1308 |
$col = 0; |
| 1309 |
while ($node) { |
| 1310 |
if ($node->getNodeType == XML::DOM::ELEMENT_NODE) { |
| 1311 |
$html .= formatContentModelElement($node); |
| 1312 |
} |
| 1313 |
$node = $node->getNextSibling(); |
| 1314 |
} |
| 1315 |
|
| 1316 |
return $html; |
| 1317 |
} |
| 1318 |
|
| 1319 |
sub formatContentModelElement { |
| 1320 |
my $node = shift; |
| 1321 |
my $html = ""; |
| 1322 |
|
| 1323 |
if ($node->getNodeType == XML::DOM::ELEMENT_NODE) { |
| 1324 |
if ($node->getTagName() eq 'sequence-group') { |
| 1325 |
$html .= &formatCMGroup($node, ","); |
| 1326 |
} elsif ($node->getTagName() eq 'or-group') { |
| 1327 |
$html .= &formatCMGroup($node, "|"); |
| 1328 |
} elsif ($node->getTagName() eq 'and-group') { |
| 1329 |
$html .= &formatCMGroup($node, "&"); |
| 1330 |
} elsif ($node->getTagName() eq 'element-name') { |
| 1331 |
$html .= &formatCMElement($node); |
| 1332 |
} elsif ($node->getTagName() eq 'parament-name') { |
| 1333 |
$html .= &formatCMParament($node); |
| 1334 |
} elsif ($node->getTagName() eq 'pcdata') { |
| 1335 |
$html .= &formatCMPCDATA($node); |
| 1336 |
} elsif ($node->getTagName() eq 'cdata') { |
| 1337 |
$html .= &formatCMCDATA($node); |
| 1338 |
} elsif ($node->getTagName() eq 'rcdata') { |
| 1339 |
$html .= &formatCMRCDATA($node); |
| 1340 |
} elsif ($node->getTagName() eq 'empty') { |
| 1341 |
$html .= &formatCMEMPTY($node); |
| 1342 |
} else { |
| 1343 |
die "Unexpected node: \"" . $node->getTagName() . "\"\n"; |
| 1344 |
} |
| 1345 |
$node = $node->getNextSibling(); |
| 1346 |
} else { |
| 1347 |
die "Unexpected node type.\n"; |
| 1348 |
} |
| 1349 |
|
| 1350 |
return $html; |
| 1351 |
} |
| 1352 |
|
| 1353 |
sub formatCMGroup { |
| 1354 |
my $group = shift; |
| 1355 |
my $occur = $group->getAttribute('occurrence'); |
| 1356 |
;my $sep = shift; |
| 1357 |
my $first = 1; |
| 1358 |
my $html = ""; |
| 1359 |
|
| 1360 |
if ($state ne 'NONE' && $state ne 'OPEN') { |
| 1361 |
$html .= "\n"; |
| 1362 |
$html .= " " x $depth if $depth > 0; |
| 1363 |
$col = $depth; |
| 1364 |
$state = 'NEWLINE'; |
| 1365 |
} |
| 1366 |
|
| 1367 |
$html .= "("; |
| 1368 |
$state = 'OPEN'; |
| 1369 |
$depth++; |
| 1370 |
$col++; |
| 1371 |
|
| 1372 |
my $node = $group->getFirstChild(); |
| 1373 |
while ($node) { |
| 1374 |
if ($node->getNodeType() == XML::DOM::ELEMENT_NODE) { |
| 1375 |
if (!$first) { |
| 1376 |
my $name = $node->getAttribute('name'); |
| 1377 |
my $occur = $node->getAttribute('occurrence'); |
| 1378 |
|
| 1379 |
$html .= $sep; |
| 1380 |
$col++; |
| 1381 |
|
| 1382 |
if ($state ne 'NEWLINE' |
| 1383 |
&& ($col + length($name) + length($occur) > 65)) { |
| 1384 |
$html .= "\n"; |
| 1385 |
$html .= " " x $depth if $depth > 0; |
| 1386 |
$col = $depth; |
| 1387 |
$state = 'NEWLINE'; |
| 1388 |
} |
| 1389 |
} |
| 1390 |
$html .= &formatContentModelElement($node); |
| 1391 |
$first = 0; |
| 1392 |
} |
| 1393 |
$node = $node->getNextSibling(); |
| 1394 |
} |
| 1395 |
|
| 1396 |
$html .= ")"; |
| 1397 |
$col++; |
| 1398 |
|
| 1399 |
if ($occur) { |
| 1400 |
$html .= $occur; |
| 1401 |
$col++; |
| 1402 |
} |
| 1403 |
|
| 1404 |
$state = 'CLOSE'; |
| 1405 |
$depth--; |
| 1406 |
|
| 1407 |
return $html; |
| 1408 |
} |
| 1409 |
|
| 1410 |
sub formatCMElement { |
| 1411 |
my $element = shift; |
| 1412 |
my $name = $element->getAttribute('name'); |
| 1413 |
my $occur = $element->getAttribute('occurrence'); |
| 1414 |
my $html = ""; |
| 1415 |
|
| 1416 |
$name = lc($name) if !$option{'case-sensitive'}; |
| 1417 |
|
| 1418 |
if ($state eq 'CLOSE') { |
| 1419 |
$html .= "\n"; |
| 1420 |
$html .= " " x $depth if $depth > 0; |
| 1421 |
$col = $depth; |
| 1422 |
$state = 'NEWLINE'; |
| 1423 |
} |
| 1424 |
|
| 1425 |
# $html .= "<link linkend='$baseid.elem.$name'>"; |
| 1426 |
$html .= "<sgmltag>"; |
| 1427 |
$html .= $element->getAttribute('name'); |
| 1428 |
$html .= "</sgmltag>"; |
| 1429 |
# $html .= "</link>"; |
| 1430 |
$col += length($name); |
| 1431 |
|
| 1432 |
if ($occur) { |
| 1433 |
$html .= $occur; |
| 1434 |
$col++; |
| 1435 |
} |
| 1436 |
|
| 1437 |
$state = 'ELEMENT'; |
| 1438 |
|
| 1439 |
return $html; |
| 1440 |
} |
| 1441 |
|
| 1442 |
sub formatCMParament { |
| 1443 |
my $element = shift; |
| 1444 |
my $name = $element->getAttribute('name'); |
| 1445 |
my $html = ""; |
| 1446 |
|
| 1447 |
if ($state eq 'CLOSE') { |
| 1448 |
$html .= "\n"; |
| 1449 |
$html .= " " x $depth if $depth > 0; |
| 1450 |
$col = $depth; |
| 1451 |
$state = 'NEWLINE'; |
| 1452 |
} |
| 1453 |
|
| 1454 |
# $html .= "<link linkend='$baseid.param.$name'>"; |
| 1455 |
$html .= "<sgmltag class=\"paramentity\">"; |
| 1456 |
$html .= $name; |
| 1457 |
$html .= "</sgmltag>"; |
| 1458 |
# $html .= "</link>"; |
| 1459 |
$col += length($name) + 2; |
| 1460 |
|
| 1461 |
$state = 'PARAMENT'; |
| 1462 |
|
| 1463 |
return $html; |
| 1464 |
} |
| 1465 |
|
| 1466 |
sub formatCMPCDATA { |
| 1467 |
my $html = ""; |
| 1468 |
|
| 1469 |
$html .= "#PCDATA"; |
| 1470 |
$col += 7; |
| 1471 |
$state = 'PCDATA'; |
| 1472 |
|
| 1473 |
return $html; |
| 1474 |
} |
| 1475 |
|
| 1476 |
sub formatCMCDATA { |
| 1477 |
my $html = ""; |
| 1478 |
|
| 1479 |
$html .= "CDATA"; |
| 1480 |
$col += 5; |
| 1481 |
$state = 'CDATA'; |
| 1482 |
|
| 1483 |
return $html; |
| 1484 |
} |
| 1485 |
|
| 1486 |
sub formatCMRCDATA { |
| 1487 |
my $html = ""; |
| 1488 |
|
| 1489 |
$html .= "RCDATA"; |
| 1490 |
$col += 5; |
| 1491 |
$state = 'RCDATA'; |
| 1492 |
|
| 1493 |
return $html; |
| 1494 |
} |
| 1495 |
|
| 1496 |
sub formatCMEMPTY { |
| 1497 |
my $html = ""; |
| 1498 |
|
| 1499 |
$html .= "EMPTY"; |
| 1500 |
$col += 5; |
| 1501 |
$state = 'EMPTY'; |
| 1502 |
|
| 1503 |
return $html; |
| 1504 |
} |
| 1505 |
|
| 1506 |
# ====================================================================== |
| 1507 |
|
| 1508 |
sub formatEntity { |
| 1509 |
my $count = shift; |
| 1510 |
my $name = $entities[$count]; |
| 1511 |
my $entity = $entities{$name}; |
| 1512 |
my $html = ""; |
| 1513 |
|
| 1514 |
my $textnl, $altnl; |
| 1515 |
|
| 1516 |
if ($expanded eq 'expanded') { |
| 1517 |
$textnl = $entity->getElementsByTagName("text-expanded"); |
| 1518 |
$altnl = $entity->getElementsByTagName("text"); |
| 1519 |
} else { |
| 1520 |
$textnl = $entity->getElementsByTagName("text"); |
| 1521 |
$altnl = $entity->getElementsByTagName("text-expanded"); |
| 1522 |
} |
| 1523 |
|
| 1524 |
# Hack; we're appending to a single file, just return the VLE synopsis... |
| 1525 |
return &formatEntityVLESynopsis($count, $textnl, $altnl); |
| 1526 |
|
| 1527 |
$html .= &formatEntityHeader($count); |
| 1528 |
|
| 1529 |
$html .= &formatEntityTitle($count); |
| 1530 |
|
| 1531 |
$html .= &formatEntitySynopsis($count, $textnl, $altnl) |
| 1532 |
if $option{'synopsis'}; |
| 1533 |
|
| 1534 |
$html .= &formatEntityAppearsIn($count) if $option{'appears-in'}; |
| 1535 |
|
| 1536 |
$html .= &formatEntityDescription($count) if $option{'description'}; |
| 1537 |
|
| 1538 |
$html .= &formatEntityExamples($count) if $option{'examples'}; |
| 1539 |
|
| 1540 |
$html .= &formatEntityFooter($count); |
| 1541 |
|
| 1542 |
return $html; |
| 1543 |
} |
| 1544 |
|
| 1545 |
sub formatEntityHeader { |
| 1546 |
my $count = shift; |
| 1547 |
my $html = ""; |
| 1548 |
my $name = $entities[$count]; |
| 1549 |
|
| 1550 |
$html .= "<refentry id=\"$name.parament\">\n"; |
| 1551 |
$html .= "<!-- Generated by DTDParse version $VERSION -->\n"; |
| 1552 |
$html .= "<!-- see http://www.sf.net/projects/dtdparse/ -->\n\n"; |
| 1553 |
|
| 1554 |
return $html; |
| 1555 |
} |
| 1556 |
|
| 1557 |
sub formatEntityTitle { |
| 1558 |
my $count = shift; |
| 1559 |
my $name = $entities[$count]; |
| 1560 |
my $entity = $entities{$name}; |
| 1561 |
my $type = $entity->getAttribute("type"); |
| 1562 |
my $html = ""; |
| 1563 |
|
| 1564 |
# $html .= "<![ %" . "$baseid.ms.param.refmeta; [\n"; |
| 1565 |
$html .= "<refmeta>\n"; |
| 1566 |
$html .= "<refentrytitle>"; |
| 1567 |
$html .= $entity->getAttribute('name'); |
| 1568 |
$html .= "</refentrytitle>\n"; |
| 1569 |
|
| 1570 |
if ($type eq 'gen') { |
| 1571 |
$html .= "<refmiscinfo>General Entity</refmiscinfo>\n"; |
| 1572 |
} else { |
| 1573 |
$html .= "<refmiscinfo>Parameter Entity</refmiscinfo>\n"; |
| 1574 |
} |
| 1575 |
|
| 1576 |
$html .= "</refmeta>\n"; |
| 1577 |
# $html .= "]]>\n\n"; |
| 1578 |
|
| 1579 |
$html .= "<refnamediv>\n"; |
| 1580 |
$html .= "<refname>" . $entity->getAttribute('name') . "</refname>\n"; |
| 1581 |
$html .= "<refpurpose>"; |
| 1582 |
$html .= &entityRefpurpose($count); |
| 1583 |
$html .= "</refpurpose>\n"; |
| 1584 |
$html .= "</refnamediv>\n\n"; |
| 1585 |
} |
| 1586 |
|
| 1587 |
sub formatEntitySynopsis { |
| 1588 |
my $count = shift; |
| 1589 |
my $textnl = shift; |
| 1590 |
my $altnl = shift; |
| 1591 |
my $name = $entities[$count]; |
| 1592 |
my $entity = $entities{$name}; |
| 1593 |
my $html = ""; |
| 1594 |
my $type = $entity->getAttribute("type"); |
| 1595 |
my $public = $entity->getAttribute("public"); |
| 1596 |
my $system = $entity->getAttribute("system"); |
| 1597 |
my $text = ""; |
| 1598 |
|
| 1599 |
if ($textnl->getLength() > 0) { |
| 1600 |
my $textnode = $textnl->item(0); |
| 1601 |
my $content = $textnode->getFirstChild(); |
| 1602 |
if ($content) { |
| 1603 |
$text = $content->getData(); |
| 1604 |
} else { |
| 1605 |
$text = ""; |
| 1606 |
} |
| 1607 |
} |
| 1608 |
|
| 1609 |
# $html .= "<![ %" . "$baseid.ms.param.refsynopsisdiv; [\n"; |
| 1610 |
$html .= "<refsynopsisdiv>\n"; |
| 1611 |
$html .= "<informaltable frame='all' role='elemsynop'>\n"; |
| 1612 |
$html .= "<tgroup cols='3'>\n"; |
| 1613 |
$html .= "<colspec colnum='1' colname='c1'/>\n"; |
| 1614 |
$html .= "<colspec colnum='2' colname='c2'/>\n"; |
| 1615 |
$html .= "<colspec colnum='3' colname='c3'/>\n"; |
| 1616 |
$html .= "<tbody>\n"; |
| 1617 |
|
| 1618 |
$html .= "<row rowsep='0' role='cmtitle'>\n"; |
| 1619 |
$html .= "<entry namest='c1' nameend='c3' align='left'\n"; |
| 1620 |
$html .= "><emphasis role='bold'>"; |
| 1621 |
|
| 1622 |
if ($type eq 'gen') { |
| 1623 |
$html .= "General Entity"; |
| 1624 |
$html .= "</emphasis></entry>\n"; |
| 1625 |
$html .= "</row>\n"; |
| 1626 |
$html .= "<row rowsep='1' role='cmsynop'>\n"; |
| 1627 |
$html .= "<entry namest='c1' nameend='c3' align='left'\n"; |
| 1628 |
$html .= "><synopsis>"; |
| 1629 |
|
| 1630 |
if ($text =~ /\"/) { |
| 1631 |
$html .= "'$text'\n"; |
| 1632 |
} else { |
| 1633 |
$html .= "\"$text\"\n"; |
| 1634 |
} |
| 1635 |
|
| 1636 |
$html .= "</synopsis></entry>\n"; |
| 1637 |
$html .= "</row>\n"; |
| 1638 |
} |
| 1639 |
|
| 1640 |
if ($type eq 'param') { |
| 1641 |
if ($public || $system) { |
| 1642 |
$html .= "External Entity"; |
| 1643 |
$html .= "</emphasis></entry>\n"; |
| 1644 |
$html .= "</row>\n"; |
| 1645 |
$html .= "<row rowsep='1' role='cmsynop'>\n"; |
| 1646 |
$html .= "<entry namest='c1' nameend='c3' align='left'\n"; |
| 1647 |
$html .= ">"; |
| 1648 |
|
| 1649 |
$html .= "<para><emphasis role='bold'>Public identifier</emphasis>: $public\n</para>" if $public; |
| 1650 |
$html .= "<para><emphasis role='bold'>System identifier</emphasis>: $system\n</para>" if $system; |
| 1651 |
|
| 1652 |
$html .= "</entry>\n"; |
| 1653 |
$html .= "</row>\n"; |
| 1654 |
} else { |
| 1655 |
$html .= "Parameter Entity\n"; |
| 1656 |
$html .= "</emphasis></entry>\n"; |
| 1657 |
$html .= "</row>\n"; |
| 1658 |
$html .= "<row rowsep='1' role='cmsynop'>\n"; |
| 1659 |
$html .= "<entry namest='c1' nameend='c3' align='left'\n"; |
| 1660 |
|
| 1661 |
if ($text eq '') { |
| 1662 |
$html .= "><para>"; |
| 1663 |
$html .= "The replacement text for this entity is empty."; |
| 1664 |
$html .= "</para>"; |
| 1665 |
} else { |
| 1666 |
$html .= "><synopsis>"; |
| 1667 |
$html .= &formatEntitySynopsisContent($text); |
| 1668 |
$html .= "</synopsis>"; |
| 1669 |
} |
| 1670 |
|
| 1671 |
$html .= "</entry>\n"; |
| 1672 |
$html .= "</row>\n"; |
| 1673 |
|
| 1674 |
# output the expanded version as well, in the unexpanded case |
| 1675 |
if ($expanded eq 'unexpanded') { |
| 1676 |
if ($altnl->getLength() > 0) { |
| 1677 |
my $textnode = $altnl->item(0); |
| 1678 |
my $content = $textnode->getFirstChild(); |
| 1679 |
if ($content) { |
| 1680 |
$text = $content->getData(); |
| 1681 |
} else { |
| 1682 |
$text = ""; |
| 1683 |
} |
| 1684 |
} |
| 1685 |
|
| 1686 |
$html .= "<row rowsep='0' role='cmtitle'>\n"; |
| 1687 |
$html .= "<entry namest='c1' nameend='c3' align='left'\n"; |
| 1688 |
$html .= "><emphasis role='bold'>"; |
| 1689 |
$html .= "Parameter Entity (Expanded)\n"; |
| 1690 |
$html .= "</emphasis></entry>\n"; |
| 1691 |
$html .= "</row>\n"; |
| 1692 |
$html .= "<row rowsep='1' role='cmsynop'>\n"; |
| 1693 |
$html .= "<entry namest='c1' nameend='c3' align='left'\n"; |
| 1694 |
|
| 1695 |
if ($text eq '') { |
| 1696 |
$html .= "><para>"; |
| 1697 |
$html .= "The replacement text for this entity is empty."; |
| 1698 |
$html .= "</para>"; |
| 1699 |
} else { |
| 1700 |
$html .= "><synopsis>"; |
| 1701 |
$html .= &formatEntitySynopsisContent($text); |
| 1702 |
$html .= "</synopsis>"; |
| 1703 |
} |
| 1704 |
|
| 1705 |
$html .= "</entry>\n"; |
| 1706 |
$html .= "</row>\n"; |
| 1707 |
} |
| 1708 |
} |
| 1709 |
} |
| 1710 |
|
| 1711 |
$html .= "</tbody>\n"; |
| 1712 |
$html .= "</tgroup>\n"; |
| 1713 |
$html .= "</informaltable>\n"; |
| 1714 |
$html .= "</refsynopsisdiv>\n\n"; |
| 1715 |
|
| 1716 |
return $html; |
| 1717 |
} |
| 1718 |
|
| 1719 |
sub formatEntityVLESynopsis { |
| 1720 |
my $count = shift; |
| 1721 |
my $textnl = shift; |
| 1722 |
my $altnl = shift; |
| 1723 |
my $name = $entities[$count]; |
| 1724 |
my $entity = $entities{$name}; |
| 1725 |
my $html = ""; |
| 1726 |
my $type = $entity->getAttribute("type"); |
| 1727 |
my $public = $entity->getAttribute("public"); |
| 1728 |
my $system = $entity->getAttribute("system"); |
| 1729 |
my $text = ""; |
| 1730 |
my %attr = (); |
| 1731 |
|
| 1732 |
if ($textnl->getLength() > 0) { |
| 1733 |
my $textnode = $textnl->item(0); |
| 1734 |
my $content = $textnode->getFirstChild(); |
| 1735 |
if ($content) { |
| 1736 |
$text = $content->getData(); |
| 1737 |
} else { |
| 1738 |
$text = ""; |
| 1739 |
} |
| 1740 |
} |
| 1741 |
|
| 1742 |
$html .= "<informaltable frame='all' role='elemsynop'>\n"; |
| 1743 |
$html .= "<tgroup cols='3'>\n"; |
| 1744 |
$html .= "<colspec colnum='1' colname='c1'/>\n"; |
| 1745 |
$html .= "<colspec colnum='2' colname='c2'/>\n"; |
| 1746 |
$html .= "<colspec colnum='3' colname='c3'/>\n"; |
| 1747 |
$html .= "<tbody>\n"; |
| 1748 |
|
| 1749 |
$html .= "<row rowsep='0' role='vle-cmtitle'>\n"; |
| 1750 |
$html .= "<entry namest='c1' nameend='c3' align='left'\n"; |
| 1751 |
$html .= "><emphasis role='bold'>"; |
| 1752 |
|
| 1753 |
if ($type eq 'gen') { |
| 1754 |
$html .= "General Entity"; |
| 1755 |
$html .= "</emphasis></entry>\n"; |
| 1756 |
$html .= "</row>\n"; |
| 1757 |
$html .= "<row rowsep='1' role='cmsynop'>\n"; |
| 1758 |
$html .= "<entry namest='c1' nameend='c3' align='left'\n"; |
| 1759 |
$html .= "><synopsis>"; |
| 1760 |
|
| 1761 |
if ($text =~ /\"/) { |
| 1762 |
$html .= "'$text'\n"; |
| 1763 |
} else { |
| 1764 |
$html .= "\"$text\"\n"; |
| 1765 |
} |
| 1766 |
|
| 1767 |
$html .= "</synopsis></entry>\n"; |
| 1768 |
$html .= "</row>\n"; |
| 1769 |
} |
| 1770 |
|
| 1771 |
if ($type eq 'param') { |
| 1772 |
if ($public || $system) { |
| 1773 |
$html .= "External Entity"; |
| 1774 |
$html .= "</emphasis></entry>\n"; |
| 1775 |
$html .= "</row>\n"; |
| 1776 |
$html .= "<row rowsep='1' role='cmsynop'>\n"; |
| 1777 |
$html .= "<entry namest='c1' nameend='c3' align='left'\n"; |
| 1778 |
$html .= ">"; |
| 1779 |
|
| 1780 |
$html .= "<para><emphasis role='bold'>Public identifier</emphasis>: $public\n</para>" if $public; |
| 1781 |
$html .= "<para><emphasis role='bold'>System identifier</emphasis>: $system\n</para>" if $system; |
| 1782 |
|
| 1783 |
$html .= "</entry>\n"; |
| 1784 |
$html .= "</row>\n"; |
| 1785 |
} else { |
| 1786 |
$html .= "Parameter Entity\n"; |
| 1787 |
$html .= "</emphasis></entry>\n"; |
| 1788 |
$html .= "</row>\n"; |
| 1789 |
|
| 1790 |
my $temptext = $text; |
| 1791 |
$temptext =~ s/--.*?--//sg; |
| 1792 |
|
| 1793 |
if (($name =~ /\.attrib$/ |
| 1794 |
|| $name eq 'bodyatt' |
| 1795 |
|| $name eq 'secur' |
| 1796 |
|| $name eq 'tbl.table.att' |
| 1797 |
|| $name eq 'tbl.tgroup.att') |
| 1798 |
&& ($temptext ne "") |
| 1799 |
&& ($expanded eq 'expanded')) { |
| 1800 |
my $table; |
| 1801 |
($table, %attr) = &formatEntityAttributeContent($temptext); |
| 1802 |
$html .= $table; |
| 1803 |
} else { |
| 1804 |
$html .= "<row rowsep='1' role='cmsynop'>\n"; |
| 1805 |
$html .= "<entry namest='c1' nameend='c3' align='left'\n"; |
| 1806 |
|
| 1807 |
if ($temptext eq '') { |
| 1808 |
$html .= "><para>"; |
| 1809 |
$html .= "The replacement text for this entity is empty."; |
| 1810 |
$html .= "</para>"; |
| 1811 |
} else { |
| 1812 |
$html .= "><synopsis>"; |
| 1813 |
$html .= &formatEntitySynopsisContent($text); |
| 1814 |
$html .= "</synopsis>"; |
| 1815 |
} |
| 1816 |
|
| 1817 |
$html .= "</entry>\n"; |
| 1818 |
$html .= "</row>\n"; |
| 1819 |
} |
| 1820 |
|
| 1821 |
# output the expanded version as well, in the unexpanded case |
| 1822 |
if ($expanded eq 'unexpanded') { |
| 1823 |
if ($altnl->getLength() > 0) { |
| 1824 |
my $textnode = $altnl->item(0); |
| 1825 |
my $content = $textnode->getFirstChild(); |
| 1826 |
if ($content) { |
| 1827 |
$text = $content->getData(); |
| 1828 |
} else { |
| 1829 |
$text = ""; |
| 1830 |
} |
| 1831 |
} |
| 1832 |
|
| 1833 |
$html .= "<row rowsep='0' role='cmtitle'>\n"; |
| 1834 |
$html .= "<entry namest='c1' nameend='c3' align='left'\n"; |
| 1835 |
$html .= "><emphasis role='bold'>"; |
| 1836 |
$html .= "Parameter Entity (Expanded)\n"; |
| 1837 |
$html .= "</emphasis></entry>\n"; |
| 1838 |
$html .= "</row>\n"; |
| 1839 |
|
| 1840 |
my $temptext = $text; |
| 1841 |
$temptext =~ s/--.*?--//sg; |
| 1842 |
|
| 1843 |
$html .= "<row rowsep='1' role='cmsynop'>\n"; |
| 1844 |
$html .= "<entry namest='c1' nameend='c3' align='left'\n"; |
| 1845 |
|
| 1846 |
if ($temptext eq '') { |
| 1847 |
$html .= "><para>"; |
| 1848 |
$html .= "The replacement text for this entity is empty."; |
| 1849 |
$html .= "</para>"; |
| 1850 |
} else { |
| 1851 |
$html .= "><synopsis>"; |
| 1852 |
$html .= &formatEntitySynopsisContent($text); |
| 1853 |
$html .= "</synopsis>"; |
| 1854 |
} |
| 1855 |
|
| 1856 |
$html .= "</entry>\n"; |
| 1857 |
$html .= "</row>\n"; |
| 1858 |
} |
| 1859 |
} |
| 1860 |
} |
| 1861 |
|
| 1862 |
$html .= &formatEntityVLEAppearsIn($name); |
| 1863 |
|
| 1864 |
$html .= "</tbody>\n"; |
| 1865 |
$html .= "</tgroup>\n"; |
| 1866 |
$html .= "</informaltable>\n"; |
| 1867 |
|
| 1868 |
# On further consideration, don't do this. Let users look at the individual |
| 1869 |
# elements for attribute description. |
| 1870 |
# if (%attr) { |
| 1871 |
# $html .= &formatEntityAttributeDesc($name, %attr); |
| 1872 |
# } |
| 1873 |
|
| 1874 |
return $html; |
| 1875 |
} |
| 1876 |
|
| 1877 |
sub formatEntityAttributeContent { |
| 1878 |
my $text = shift; |
| 1879 |
my $html = ""; |
| 1880 |
my %attrs = (); |
| 1881 |
my %cmnatt = ('id' => 0, |
| 1882 |
'role' => 0, |
| 1883 |
'lang' => 0, |
| 1884 |
'remap'=> 0, |
| 1885 |
'xreflabel' => 0, |
| 1886 |
'revisionflag' => 0, |
| 1887 |
'arch' => 0, |
| 1888 |
'conformance' => 0, |
| 1889 |
'os' => 0, |
| 1890 |
'revision' => 0, |
| 1891 |
'userlevel' => 0, |
| 1892 |
'vendor' => 0, |
| 1893 |
'security' => 0, |
| 1894 |
'condition' => 0); |
| 1895 |
|
| 1896 |
# This function is only called if $text is not empty. |
| 1897 |
# Interpret it as a well-formed section of an attlist decl |
| 1898 |
$text =~ s/--.*?--//sg; |
| 1899 |
# $html .= "<!-- $text -->\n"; |
| 1900 |
|
| 1901 |
$html .= "<row rowsep='1' role='attrheader'>\n"; |
| 1902 |
$html .= "<entry role='th'><para><emphasis role='bold'>Name</emphasis></para></entry>\n"; |
| 1903 |
$html .= "<entry role='th'><para><emphasis role='bold'>Type</emphasis></para></entry>\n"; |
| 1904 |
$html .= "<entry role='th'><para><emphasis role='bold'>Default</emphasis></para></entry>\n"; |
| 1905 |
$html .= "</row>\n"; |
| 1906 |
|
| 1907 |
$text =~ s/\n/ /sg; # make it all one line.. |
| 1908 |
|
| 1909 |
while ($text !~ /^\s*$/) { |
| 1910 |
$html .= "<row role='attr'>\n"; |
| 1911 |
|
| 1912 |
$text =~ /^\s*(\S+)(.*?)$/; |
| 1913 |
my $token = $1; |
| 1914 |
$text = $2; |
| 1915 |
|
| 1916 |
$attrs{$token} = 1 if !defined($cmnatt{lc($token)}); |
| 1917 |
|
| 1918 |
$html .= "<entry align='left' valign='top'>$token</entry>\n"; |
| 1919 |
|
| 1920 |
$text =~ /^\s*(\S+)(.*?)$/; |
| 1921 |
$token = $1; |
| 1922 |
$text = $2; |
| 1923 |
|
| 1924 |
if ($token =~ /NOTATION/ |
| 1925 |
|| $token =~ /^\s*\(/) { |
| 1926 |
$html .= "<entry align='left' valign='top'><para>"; |
| 1927 |
if ($token =~ /NOTATION/) { |
| 1928 |
$html .= "<emphasis>Enumerated notation:</emphasis>"; |
| 1929 |
$text =~ /^\s*(\S+)\s+(.*)$/; |
| 1930 |
$token = $1; |
| 1931 |
$text = $2; |
| 1932 |
} else { |
| 1933 |
$html .= "<emphasis>Enumerated:</emphasis>"; |
| 1934 |
} |
| 1935 |
$html .= "</para><simplelist>"; |
| 1936 |
|
| 1937 |
if ($token =~ /\)\s*$/) { |
| 1938 |
# we got the whole thing... |
| 1939 |
} else { |
| 1940 |
$text =~ /^(.*?)\)/; |
| 1941 |
$token .= $1; |
| 1942 |
$text = $'; # ' |
| 1943 |
} |
| 1944 |
|
| 1945 |
$token =~ s/[\(\)\|]/ /sg; |
| 1946 |
$token =~ s/^\s*//sg; |
| 1947 |
$token =~ s/\s*$//sg; |
| 1948 |
my @members = split(/\s+/, $token); |
| 1949 |
foreach my $member (@members) { |
| 1950 |
$html .= "<member>$member</member>\n"; |
| 1951 |
} |
| 1952 |
|
| 1953 |
$html .= "</simplelist></entry>\n"; |
| 1954 |
} else { |
| 1955 |
$html .= "<entry align='left' valign='top'>$token</entry>\n"; |
| 1956 |
} |
| 1957 |
|
| 1958 |
$text =~ /^\s*(\S+)(.*?)$/s; |
| 1959 |
$token = $1; |
| 1960 |
$text = $2; |
| 1961 |
|
| 1962 |
if ($token eq '#IMPLIED') { |
| 1963 |
$token = "<emphasis>None</emphasis>"; |
| 1964 |
} elsif ($token eq '#REQUIRED') { |
| 1965 |
$token = "<emphasis>Required</emphasis>"; |
| 1966 |
} elsif ($token eq '#CONREF') { |
| 1967 |
$token = "<emphasis>Content reference</emphasis>"; |
| 1968 |
} |
| 1969 |
|
| 1970 |
$html .= "<entry align='left' valign='top'>$token</entry>\n"; |
| 1971 |
$html .= "</row>\n"; |
| 1972 |
} |
| 1973 |
|
| 1974 |
return ($html, %attrs); |
| 1975 |
} |
| 1976 |
|
| 1977 |
sub formatEntityAttributeDesc { |
| 1978 |
my $name = shift; |
| 1979 |
my %attrs = @_; |
| 1980 |
my $html = ""; |
| 1981 |
|
| 1982 |
# find an element that uses entity %name |
| 1983 |
if (!defined($EAPPEARSIN{"%$name"})) { |
| 1984 |
print "No EA for %$name\n"; |
| 1985 |
return $html; |
| 1986 |
} |
| 1987 |
|
| 1988 |
my %elem = %{$EAPPEARSIN{"%$name"}}; |
| 1989 |
my @elems = keys %elem; |
| 1990 |
my $elemname = $elems[0]; |
| 1991 |
|
| 1992 |
$html .= "<para><emphasis role='bold'>Attribute descriptions:"; |
| 1993 |
$html .= "</emphasis></para>\n"; |
| 1994 |
|
| 1995 |
$html .= "<variablelist>\n"; |
| 1996 |
foreach my $attr (sort keys %attrs) { |
| 1997 |
$html .= "<varlistentry><term>$attr</term>\n"; |
| 1998 |
$html .= "<listitem>\n"; |
| 1999 |
$html .= "&attr." . lc($attr) . ".$elemname;\n"; |
| 2000 |
$html .= "</listitem>\n"; |
| 2001 |
$html .= "</varlistentry>\n"; |
| 2002 |
} |
| 2003 |
$html .= "</variablelist>\n"; |
| 2004 |
|
| 2005 |
return $html; |
| 2006 |
} |
| 2007 |
|
| 2008 |
sub formatEntityVLEAppearsIn { |
| 2009 |
my $name = shift; |
| 2010 |
my $html = ""; |
| 2011 |
|
| 2012 |
my %appears = %{$EAPPEARSIN{"%$name"}} if exists $EAPPEARSIN{"%$name"}; |
| 2013 |
|
| 2014 |
if (%appears) { |
| 2015 |
my @ents = sort { uc($a) cmp uc($b) } keys %appears; |
| 2016 |
|
| 2017 |
$html .= "<row rowsep='0' role='vle-petitle'>\n"; |
| 2018 |
$html .= "<entry namest='c1' nameend='c3' align='left'\n"; |
| 2019 |
$html .= "><emphasis role='bold'>%$name; appears in:</emphasis>"; |
| 2020 |
$html .= "</entry>\n"; |
| 2021 |
$html .= "</row>\n"; |
| 2022 |
|
| 2023 |
while (@ents) { |
| 2024 |
$html .= "<row rowsep='0' role='vle-pe'>\n"; |
| 2025 |
|
| 2026 |
for (my $count = 0; $count < 3; $count++) { |
| 2027 |
my $name = shift @ents; |
| 2028 |
if ($name) { |
| 2029 |
my $elem = $elements{$name}; |
| 2030 |
die "Cannot find element $name\n" if !$elem; |
| 2031 |
$html .= "<entry colsep='0'>"; |
| 2032 |
$html .= "<sgmltag>"; |
| 2033 |
$html .= $elem->getAttribute('name'); |
| 2034 |
$html .= "</sgmltag>"; |
| 2035 |
$html .= "</entry>\n"; |
| 2036 |
} else { |
| 2037 |
$html .= "<entry colsep='0'></entry>\n"; |
| 2038 |
} |
| 2039 |
} |
| 2040 |
|
| 2041 |
$html .= "</row>\n"; |
| 2042 |
} |
| 2043 |
} |
| 2044 |
|
| 2045 |
return $html; |
| 2046 |
} |
| 2047 |
|
| 2048 |
sub formatEntitySynopsisContent { |
| 2049 |
my $text = shift; |
| 2050 |
my $html = ""; |
| 2051 |
|
| 2052 |
# OK, it's a parameter entity. Now, does it look like a |
| 2053 |
# content model fragment |
| 2054 |
|
| 2055 |
my $cmfragment = &cmFragment($text); |
| 2056 |
|
| 2057 |
while ($text =~ /\%?[-a-z0-9.:_]+;?/is) { |
| 2058 |
my $pre = $`; |
| 2059 |
my $match = $&; |
| 2060 |
$text = $'; # ' |
| 2061 |
|
| 2062 |
$html .= $pre; |
| 2063 |
|
| 2064 |
if ($pre =~ /\#$/) { |
| 2065 |
# if it comes after a '#', it's a keyword... |
| 2066 |
$html .= $match; |
| 2067 |
next; |
| 2068 |
} |
| 2069 |
|
| 2070 |
if ($match =~ /\%([^;]+);?/) { |
| 2071 |
$name = $1; |
| 2072 |
if (exists $entities{$name}) { |
| 2073 |
# $html .= "<link linkend=\"$baseid.param.$name\">"; |
| 2074 |
$html .= $match; |
| 2075 |
# $html .= "</link>"; |
| 2076 |
} else { |
| 2077 |
$html .= $match; |
| 2078 |
} |
| 2079 |
} elsif ($cmfragment) { |
| 2080 |
$name = $match; |
| 2081 |
$name = lc($name) if !$option{'case-sensitive'}; |
| 2082 |
if (exists $elements{$name}) { |
| 2083 |
my $linkend = "$baseid.elem.$name"; |
| 2084 |
# $html .= "<link linkend=\"$linkend\">"; |
| 2085 |
$html .= "$match"; |
| 2086 |
# $html .= "</link>"; |
| 2087 |
} else { |
| 2088 |
$html .= $match; |
| 2089 |
} |
| 2090 |
} else { |
| 2091 |
$html .= $match; |
| 2092 |
} |
| 2093 |
} |
| 2094 |
|
| 2095 |
return $html; |
| 2096 |
} |
| 2097 |
|
| 2098 |
sub formatEntityAppearsIn { |
| 2099 |
my $count = shift; |
| 2100 |
my $html = ""; |
| 2101 |
my $entityname = $entities[$count]; |
| 2102 |
my $entity = $entities{$entityname}; |
| 2103 |
my %appears = (); |
| 2104 |
my $key = "%$entityname"; |
| 2105 |
|
| 2106 |
if (exists $APPEARSIN{$key}) { |
| 2107 |
%appears = %{$APPEARSIN{$key}}; |
| 2108 |
my @ents = sort { uc($a) cmp uc($b) } keys %appears; |
| 2109 |
|
| 2110 |
# $html .= "<![ %" . "$baseid.ms.param.refsynopsisdiv.pe; [\n"; |
| 2111 |
$html .= "<refsect1 condition='ref.rsdiv.pe'><title>Parameter Entities</title>\n"; |
| 2112 |
$html .= "<para>The following parameter entities contain "; |
| 2113 |
$html .= "<sgmltag class=\"paramentity\">"; |
| 2114 |
$html .= $entity->getAttribute('name'); |
| 2115 |
$html .= "</sgmltag>:\n"; |
| 2116 |
$html .= "<simplelist type='inline'>\n"; |
| 2117 |
|
| 2118 |
for (my $count = 0; $count <= $#ents; $count++) { |
| 2119 |
my $entity = $entities{$ents[$count]}; |
| 2120 |
$html .= "<member>"; |
| 2121 |
# $html .= "<link linkend=\"$baseid."; |
| 2122 |
# $html .= $entity->getAttribute('type') . "."; |
| 2123 |
# $html .= $entity->getAttribute('name') . "\">"; |
| 2124 |
$html .= "<sgmltag class=\"paramentity\">"; |
| 2125 |
$html .= $entity->getAttribute('name'); |
| 2126 |
$html .= "</sgmltag>"; |
| 2127 |
# $html .= "</link>"; |
| 2128 |
$html .= "</member>\n"; |
| 2129 |
} |
| 2130 |
$html .= "</simplelist></para>\n"; |
| 2131 |
$html .= "</refsect1>\n"; |
| 2132 |
# $html .= "]]>\n\n"; |
| 2133 |
} |
| 2134 |
|
| 2135 |
my $refsect = "refsect1"; |
| 2136 |
if (exists($EAPPEARSIN{$key}) && exists($XAPPEARSIN{$key})) { |
| 2137 |
$refsect = "refsect2"; |
| 2138 |
# $html .= "<![ %" . "$baseid.ms.param.refsynopsisdiv.pe; [\n"; |
| 2139 |
$html .= "<refsect1 condition='ref.rsdiv.pe'><title>Elements</title>\n"; |
| 2140 |
$html .= "<para>Some element content models are effected both\n"; |
| 2141 |
$html .= "directly and indirectly by the\n"; |
| 2142 |
$html .= "<sgmltag class=\"paramentity\">"; |
| 2143 |
$html .= $entity->getAttribute('name'); |
| 2144 |
$html .= "</sgmltag> parameter entity.</para>\n"; |
| 2145 |
} |
| 2146 |
|
| 2147 |
if (exists($EAPPEARSIN{$key})) { |
| 2148 |
%appears = %{$EAPPEARSIN{$key}}; |
| 2149 |
|
| 2150 |
my @elem = sort { uc($a) cmp uc($b) } keys %appears; |
| 2151 |
|
| 2152 |
if (exists($EAPPEARSIN{$key}) && exists($XAPPEARSIN{$key})) { |
| 2153 |
$html .= "<refsect2><title>Directly Effected</title>\n"; |
| 2154 |
|
| 2155 |
# print "\n", $entity->getAttribute('name'), " ($key):\n"; |
| 2156 |
# print "\t", $#elem, "\n"; |
| 2157 |
# foreach my $foo (keys %{$EAPPEARSIN{$key}}) { |
| 2158 |
# print "\t'$foo'='", $EAPPEARSIN{$key}->{$foo}, "'\n"; |
| 2159 |
# } |
| 2160 |
} else { |
| 2161 |
$html .= "<refsect1><title>Elements</title>\n"; |
| 2162 |
} |
| 2163 |
|
| 2164 |
$html .= "<para>The content models of the following elements\n"; |
| 2165 |
$html .= "contain "; |
| 2166 |
$html .= "<sgmltag class=\"paramentity\">"; |
| 2167 |
$html .= $entity->getAttribute('name'); |
| 2168 |
$html .= "</sgmltag> directly:\n"; |
| 2169 |
$html .= "<simplelist type='inline'>\n"; |
| 2170 |
|
| 2171 |
for (my $count = 0; $count <= $#elem; $count++) { |
| 2172 |
my $element = $elements{$elem[$count]}; |
| 2173 |
$html .= "<member>"; |
| 2174 |
# $html .= "<link linkend=\"$baseid.elem."; |
| 2175 |
# $html .= $elem[$count] . "\">"; |
| 2176 |
$html .= "<sgmltag>"; |
| 2177 |
$html .= $element->getAttribute('name'); |
| 2178 |
$html .= "</sgmltag>"; |
| 2179 |
# $html .= "</link>"; |
| 2180 |
$html .= "</member>\n"; |
| 2181 |
} |
| 2182 |
$html .= "</simplelist></para>\n"; |
| 2183 |
$html .= "</$refsect>\n"; |
| 2184 |
} |
| 2185 |
|
| 2186 |
if (exists $XAPPEARSIN{$key}) { |
| 2187 |
%appears = %{$XAPPEARSIN{$key}}; |
| 2188 |
|
| 2189 |
my @elem = sort { uc($a) cmp uc($b) } keys %appears; |
| 2190 |
|
| 2191 |
if (exists($EAPPEARSIN{$key}) && exists($XAPPEARSIN{$key})) { |
| 2192 |
$html .= "<refsect2><title>Indirectly Effected</title>\n"; |
| 2193 |
} else { |
| 2194 |
$html .= "<refsect1><title>Elements</title>\n"; |
| 2195 |
} |
| 2196 |
|
| 2197 |
$html .= "<para>The content models of the following elements\n"; |
| 2198 |
$html .= "contain "; |
| 2199 |
$html .= "<sgmltag class=\"paramentity\">"; |
| 2200 |
$html .= $entity->getAttribute('name'); |
| 2201 |
$html .= "</sgmltag> indirectly:\n"; |
| 2202 |
$html .= "<simplelist type='inline'>\n"; |
| 2203 |
|
| 2204 |
for (my $count = 0; $count <= $#elem; $count++) { |
| 2205 |
my $element = $elements{$elem[$count]}; |
| 2206 |
$html .= "<member>"; |
| 2207 |
# $html .= "<link linkend=\"$baseid.elem."; |
| 2208 |
# $html .= $elem[$count] . "\">"; |
| 2209 |
$html .= "<sgmltag>"; |
| 2210 |
$html .= $element->getAttribute('name'); |
| 2211 |
$html .= "</sgmltag>"; |
| 2212 |
# $html .= "</link>"; |
| 2213 |
$html .= "</member>\n"; |
| 2214 |
} |
| 2215 |
$html .= "</simplelist></para>\n"; |
| 2216 |
$html .= "</$refsect>\n"; |
| 2217 |
} |
| 2218 |
|
| 2219 |
$html .= "</refsect1>\n" |
| 2220 |
if (exists($EAPPEARSIN{$key}) && exists($XAPPEARSIN{$key})); |
| 2221 |
|
| 2222 |
# $html .= "]]>\n\n"; |
| 2223 |
|
| 2224 |
return $html; |
| 2225 |
} |
| 2226 |
|
| 2227 |
sub formatEntityDescription { |
| 2228 |
my $count = shift; |
| 2229 |
my $name = $entities[$count]; |
| 2230 |
my $entity = $entities{$name}; |
| 2231 |
my $desc = &entityDescription($count); |
| 2232 |
my $html = ""; |
| 2233 |
|
| 2234 |
return "" if !defined($desc); |
| 2235 |
|
| 2236 |
$html .= "<refsect1><title>Description</title>\n"; |
| 2237 |
$html .= $desc; |
| 2238 |
$html .= "</refsect1>\n\n"; |
| 2239 |
|
| 2240 |
return $html; |
| 2241 |
} |
| 2242 |
|
| 2243 |
sub formatEntityExamples { |
| 2244 |
my $count = shift; |
| 2245 |
my $name = $entities[$count]; |
| 2246 |
my $entity = $entities{$name}; |
| 2247 |
|
| 2248 |
return ""; |
| 2249 |
} |
| 2250 |
|
| 2251 |
sub formatEntityFooter { |
| 2252 |
my $count = shift; |
| 2253 |
my $html = ""; |
| 2254 |
|
| 2255 |
$html .= "</refentry>\n"; |
| 2256 |
|
| 2257 |
return $html; |
| 2258 |
} |
| 2259 |
|
| 2260 |
# ====================================================================== |
| 2261 |
|
| 2262 |
sub formatNotation { |
| 2263 |
my $count = shift; |
| 2264 |
my $html = ""; |
| 2265 |
|
| 2266 |
my $name = $notations[$count]; |
| 2267 |
my $element = $notations{$name}; |
| 2268 |
|
| 2269 |
$html .= &formatNotationHeader($count); |
| 2270 |
|
| 2271 |
$html .= &formatNotationTitle($count); |
| 2272 |
|
| 2273 |
if ($option{'synopsis'}) { |
| 2274 |
$html .= &formatNotationSynopsis($count); |
| 2275 |
} |
| 2276 |
|
| 2277 |
$html .= &formatNotationDescription($count) |
| 2278 |
if $option{'description'}; |
| 2279 |
|
| 2280 |
$html .= &formatNotationExamples($count) if $option{'examples'}; |
| 2281 |
|
| 2282 |
$html .= &formatNotationFooter($count); |
| 2283 |
} |
| 2284 |
|
| 2285 |
sub formatNotationHeader { |
| 2286 |
my $count = shift; |
| 2287 |
my $html = ""; |
| 2288 |
my $name = $notations[$count]; |
| 2289 |
|
| 2290 |
$html .= "<refentry id=\"$name.notation\">\n"; |
| 2291 |
$html .= "<!-- Generated by DTDParse version $VERSION -->\n"; |
| 2292 |
$html .= "<!-- see http://www.sf.net/projects/dtdparse/ -->\n\n"; |
| 2293 |
|
| 2294 |
return $html; |
| 2295 |
} |
| 2296 |
|
| 2297 |
sub formatNotationTitle { |
| 2298 |
my $count = shift; |
| 2299 |
my $name = $notations[$count]; |
| 2300 |
my $notation = $notations{$name}; |
| 2301 |
my $html = ""; |
| 2302 |
|
| 2303 |
$html .= "<refmeta>\n"; |
| 2304 |
$html .= "<refentrytitle>"; |
| 2305 |
$html .= $notation->getAttribute('name'); |
| 2306 |
$html .= "</refentrytitle>\n"; |
| 2307 |
$html .= "<refmiscinfo>Notation</refmiscinfo>\n"; |
| 2308 |
$html .= "</refmeta>\n\n"; |
| 2309 |
|
| 2310 |
$html .= "<refnamediv>\n"; |
| 2311 |
$html .= "<refname>" . $notation->getAttribute('name') . "</refname>\n"; |
| 2312 |
$html .= "<refpurpose>"; |
| 2313 |
$html .= ¬ationRefpurpose($count); |
| 2314 |
$html .= "</refpurpose>\n"; |
| 2315 |
$html .= "</refnamediv>\n\n"; |
| 2316 |
} |
| 2317 |
|
| 2318 |
sub formatNotationSynopsis { |
| 2319 |
my $count = shift; |
| 2320 |
my $name = $notations[$count]; |
| 2321 |
my $notation = $notations{$name}; |
| 2322 |
my $html = ""; |
| 2323 |
my $public = $notation->getAttribute("public"); |
| 2324 |
my $system = $notation->getAttribute("system"); |
| 2325 |
|
| 2326 |
$html .= "<refsynopsisdiv>\n"; |
| 2327 |
|
| 2328 |
if ($public) { |
| 2329 |
$html .= "<para>\nPublic identifier:\n"; |
| 2330 |
$html .= "<emphasis>$public</emphasis>."; |
| 2331 |
$html .= "</para>\n\n"; |
| 2332 |
} |
| 2333 |
|
| 2334 |
if ($system) { |
| 2335 |
$html .= "<para>\nSystem identifier:\n"; |
| 2336 |
$html .= "<emphasis>$system</emphasis>."; |
| 2337 |
$html .= "</para>\n\n"; |
| 2338 |
} |
| 2339 |
|
| 2340 |
if (!$public && !$system) { |
| 2341 |
$html .= "<para>\n<quote>System</quote> specified\n"; |
| 2342 |
$html .= "without a system identifier."; |
| 2343 |
$html .= "</para>\n\n"; |
| 2344 |
} |
| 2345 |
|
| 2346 |
return $html; |
| 2347 |
} |
| 2348 |
|
| 2349 |
sub formatNotationDescription { |
| 2350 |
my $count = shift; |
| 2351 |
my $name = $notations[$count]; |
| 2352 |
my $notation = $notations{$name}; |
| 2353 |
my $desc = ¬ationDescription($count); |
| 2354 |
my $html = ""; |
| 2355 |
|
| 2356 |
return "" if !defined($desc); |
| 2357 |
|
| 2358 |
$html .= "<refsect1><title>Description</title>\n"; |
| 2359 |
$html .= $desc; |
| 2360 |
$html .= "</refsect1>\n\n"; |
| 2361 |
|
| 2362 |
return $html; |
| 2363 |
} |
| 2364 |
|
| 2365 |
sub formatNotationExamples { |
| 2366 |
my $count = shift; |
| 2367 |
my $name = $notations[$count]; |
| 2368 |
my $element = $notations{$name}; |
| 2369 |
|
| 2370 |
return ""; |
| 2371 |
} |
| 2372 |
|
| 2373 |
sub formatNotationFooter { |
| 2374 |
my $count = shift; |
| 2375 |
my $html = ""; |
| 2376 |
|
| 2377 |
$html .= "</refentry>\n"; |
| 2378 |
|
| 2379 |
return $html; |
| 2380 |
} |
| 2381 |
|
| 2382 |
# ====================================================================== |
| 2383 |
|
| 2384 |
sub createDir { |
| 2385 |
my $dir = shift; |
| 2386 |
my $mode = shift; |
| 2387 |
# nop |
| 2388 |
} |
| 2389 |
|
| 2390 |
sub checkDir { |
| 2391 |
my $dir = shift; |
| 2392 |
# nop |
| 2393 |
} |
| 2394 |
|
| 2395 |
sub writeElement { |
| 2396 |
my $count = shift; |
| 2397 |
my $path = shift; |
| 2398 |
my $basename = shift; |
| 2399 |
my $fileext = shift; |
| 2400 |
my $html = shift; |
| 2401 |
my $name = $elements[$count]; |
| 2402 |
my $element = $elements{$name}; |
| 2403 |
|
| 2404 |
my $dir = $option{'base-dir'} . "/elements/$basename"; |
| 2405 |
if (! -d $dir) { |
| 2406 |
mkdir($dir, 0755); |
| 2407 |
} |
| 2408 |
|
| 2409 |
# DON'T OVERWRITE THIS FILE ANYMORE! |
| 2410 |
if (! -f "$dir/refentry$fileext") { |
| 2411 |
open (F, ">$dir/refentry$fileext"); |
| 2412 |
print F $html; |
| 2413 |
close (F); |
| 2414 |
} |
| 2415 |
|
| 2416 |
open (F, ">$dir/${prefix}entities.e.ent"); |
| 2417 |
print F "<!ENTITY $name.synopsis.gen SYSTEM \"${prefix}synopsis.e.gen\">\n" |
| 2418 |
if -f "$dir/${prefix}synopsis.e.gen"; |
| 2419 |
|
| 2420 |
foreach my $f ("children", "parents", "seealso", "example.seealso") { |
| 2421 |
print F "<!ENTITY $name.$f.gen SYSTEM \"$prefix$f.gen\">\n" |
| 2422 |
if -f "$dir/$prefix$f.gen"; |
| 2423 |
} |
| 2424 |
|
| 2425 |
for (my $count = 1; -f "$dir/example.$count.gen"; $count++) { |
| 2426 |
print F "<!ENTITY $name.example.$count.gen SYSTEM \"example.$count.gen\">\n"; |
| 2427 |
} |
| 2428 |
|
| 2429 |
for (my $count = 1; -f "$dir/example.$count.txt"; $count++) { |
| 2430 |
print F "<!ENTITY $name.example.$count.txt SYSTEM \"example.$count.txt\">\n"; |
| 2431 |
} |
| 2432 |
|
| 2433 |
close (F); |
| 2434 |
|
| 2435 |
open (F, ">$dir/${prefix}entities.u.ent"); |
| 2436 |
print F "<!ENTITY $name.synopsis.gen SYSTEM \"synopsis.u.gen\">\n" |
| 2437 |
if -f "$dir/${prefix}synopsis.u.gen"; |
| 2438 |
|
| 2439 |
foreach my $f ("children", "parents", "seealso", "example.seealso") { |
| 2440 |
print F "<!ENTITY $name.$f.gen SYSTEM \"$prefix$f.gen\">\n" |
| 2441 |
if -f "$dir/$prefix$f.gen"; |
| 2442 |
} |
| 2443 |
|
| 2444 |
for (my $count = 1; -f "$dir/example.$count.gen"; $count++) { |
| 2445 |
print F "<!ENTITY $name.example.$count.gen SYSTEM \"example.$count.gen\">\n"; |
| 2446 |
} |
| 2447 |
|
| 2448 |
for (my $count = 1; -f "$dir/example.$count.txt"; $count++) { |
| 2449 |
print F "<!ENTITY $name.example.$count.txt SYSTEM \"example.$count.txt\">\n"; |
| 2450 |
} |
| 2451 |
|
| 2452 |
close (F); |
| 2453 |
} |
| 2454 |
|
| 2455 |
sub writeEntity { |
| 2456 |
my $count = shift; |
| 2457 |
my $path = shift; |
| 2458 |
my $basename = shift; |
| 2459 |
my $fileext = shift; |
| 2460 |
my $html = shift; |
| 2461 |
my $name = $entities[$count]; |
| 2462 |
my $entity = $entities{$name}; |
| 2463 |
my $class = $entity_classes{$name}; |
| 2464 |
|
| 2465 |
# Hack; actually append a subset of the entity to a single file... |
| 2466 |
|
| 2467 |
if (!defined($class)) { |
| 2468 |
for (my $cnt = 0; $cnt <= $#entity_classes; $cnt++) { |
| 2469 |
if ($name =~ /$entity_pats[$cnt]/) { |
| 2470 |
$class = $entity_classes[$cnt]; |
| 2471 |
last; |
| 2472 |
} |
| 2473 |
} |
| 2474 |
} |
| 2475 |
|
| 2476 |
if ($class ne '') { |
| 2477 |
my $bdir = $option{'base-dir'}; |
| 2478 |
my $edir = $config{$expanded . '-entity-dir'}; |
| 2479 |
my $ext = "e.gen"; |
| 2480 |
my $entdir = "$bdir/$edir"; |
| 2481 |
my $bid = $option{'base-id'}; |
| 2482 |
local *F; |
| 2483 |
|
| 2484 |
if ($expanded ne 'expanded') { |
| 2485 |
$ext = "u.gen"; |
| 2486 |
} |
| 2487 |
|
| 2488 |
if ($class ne 'isochars') { |
| 2489 |
open (F, ">>$entdir/$class.$ext"); |
| 2490 |
print F "<refsect2 id=\"$name.parament\">"; |
| 2491 |
print F "<title>%$name;</title>\n"; |
| 2492 |
print F $html; |
| 2493 |
print F "</refsect2>\n\n"; |
| 2494 |
close (F); |
| 2495 |
} |
| 2496 |
} else { |
| 2497 |
print "No class defined for entity $name\n"; |
| 2498 |
} |
| 2499 |
} |
| 2500 |
|
| 2501 |
sub writeNotation { |
| 2502 |
my $count = shift; |
| 2503 |
my $path = shift; |
| 2504 |
my $basename = shift; |
| 2505 |
my $fileext = shift; |
| 2506 |
my $html = shift; |
| 2507 |
|
| 2508 |
# No, we're not writing individual notation pages. |
| 2509 |
# But thanks for asking. |
| 2510 |
} |
| 2511 |
|
| 2512 |
sub writeElementIndexes { |
| 2513 |
my $basedir = shift; |
| 2514 |
my $title = $dtd->getDocumentElement->getAttribute('title'); |
| 2515 |
my ($entfile, $sgmfile, $sysdir); |
| 2516 |
local (*F, $_); |
| 2517 |
|
| 2518 |
return; |
| 2519 |
|
| 2520 |
$entfile = $basedir . "/" . $config{$expanded . "-element-index"} . ".ent"; |
| 2521 |
$sgmfile = $basedir . "/" . $config{$expanded . "-element-index"} . ".sgm"; |
| 2522 |
$sysdir = $config{$expanded . "-element-dir"}; |
| 2523 |
|
| 2524 |
open (F, ">$entfile"); |
| 2525 |
foreach $name (@elements) { |
| 2526 |
my $basename = $ELEMBASE{$name}; |
| 2527 |
print F "<!ENTITY $baseid.elem.$name "; |
| 2528 |
print F "SYSTEM \"$sysdir/$basename$fileext\">\n"; |
| 2529 |
print F "<!ENTITY $baseid.purp.elem.$name \"purpose\">\n"; |
| 2530 |
} |
| 2531 |
close (F); |
| 2532 |
|
| 2533 |
open (F, ">$sgmfile"); |
| 2534 |
print F "<reference><title>$title Element Reference</title>\n"; |
| 2535 |
foreach $name (@elements) { |
| 2536 |
print F "&$baseid.elem.$name;\n"; |
| 2537 |
} |
| 2538 |
print F "</reference>\n"; |
| 2539 |
close (F); |
| 2540 |
} |
| 2541 |
|
| 2542 |
sub writeEntityIndexes { |
| 2543 |
my $basedir = shift; |
| 2544 |
my $title = $dtd->getDocumentElement->getAttribute('title'); |
| 2545 |
my ($entfile, $sgmfile, $sysdir); |
| 2546 |
local (*F, $_); |
| 2547 |
|
| 2548 |
return; |
| 2549 |
|
| 2550 |
$entfile = $basedir . "/" . $config{$expanded . "-entity-index"} . ".ent"; |
| 2551 |
$sgmfile = $basedir . "/" . $config{$expanded . "-entity-index"} . ".sgm"; |
| 2552 |
$sysdir = $config{$expanded . "-entity-dir"}; |
| 2553 |
|
| 2554 |
open (F, ">$entfile"); |
| 2555 |
foreach $name (@entities) { |
| 2556 |
my $entity = $entities{$name}; |
| 2557 |
my $basename = $ENTBASE{$name}; |
| 2558 |
print F "<!ENTITY $baseid.param.$name "; |
| 2559 |
print F "SYSTEM \"$sysdir/$basename$fileext\">\n"; |
| 2560 |
print F "<!ENTITY $baseid.purp.", $entity->getAttribute('type'), ".$name \"purpose\">\n"; |
| 2561 |
} |
| 2562 |
close (F); |
| 2563 |
|
| 2564 |
open (F, ">$sgmfile"); |
| 2565 |
print F "<reference><title>$title Entity Reference</title>\n"; |
| 2566 |
foreach $name (@entities) { |
| 2567 |
print F "&$baseid.param.$name;\n"; |
| 2568 |
} |
| 2569 |
print F "</reference>\n"; |
| 2570 |
close (F); |
| 2571 |
} |
| 2572 |
|
| 2573 |
sub writeNotationIndexes { |
| 2574 |
my $basedir = shift; |
| 2575 |
my $basedir = $option{'base-dir'}; |
| 2576 |
my $path = $basedir . "/" . $config{'notation-dir'}; |
| 2577 |
local (*F, $_); |
| 2578 |
|
| 2579 |
# hack. write the notation .gen file instead of a proper index |
| 2580 |
|
| 2581 |
$notnfile = "$path/notations.gen"; |
| 2582 |
|
| 2583 |
open (F, ">$notnfile"); |
| 2584 |
|
| 2585 |
foreach $name (sort @notations) { |
| 2586 |
$notation = $notations{$name}; |
| 2587 |
|
| 2588 |
print F "<varlistentry id=\"$name.notation\">\n"; |
| 2589 |
print F "<term>$name</term>\n"; |
| 2590 |
print F "<listitem>\n"; |
| 2591 |
|
| 2592 |
print F "<para>Public id: "; |
| 2593 |
if ($notation->getAttribute('public') ne '') { |
| 2594 |
print F "<literal>"; |
| 2595 |
print F $notation->getAttribute('public'); |
| 2596 |
print F "</literal>\n"; |
| 2597 |
} else { |
| 2598 |
print F "<emphasis>undefined</emphasis>\n"; |
| 2599 |
} |
| 2600 |
|
| 2601 |
print F "</para>\n"; |
| 2602 |
|
| 2603 |
print F "<para>System id: "; |
| 2604 |
|
| 2605 |
if ($notation->getAttribute('system') ne '') { |
| 2606 |
print F "<literal>"; |
| 2607 |
print F $notation->getAttribute('system'); |
| 2608 |
print F "</literal>\n"; |
| 2609 |
} else { |
| 2610 |
print F "<emphasis>undefined</emphasis>\n"; |
| 2611 |
} |
| 2612 |
|
| 2613 |
print F "</para>\n"; |
| 2614 |
|
| 2615 |
print F "</listitem>\n"; |
| 2616 |
print F "</varlistentry>\n"; |
| 2617 |
} |
| 2618 |
close (F); |
| 2619 |
} |
| 2620 |
|
| 2621 |
sub writeIndex { |
| 2622 |
my $basedir = shift; |
| 2623 |
my $title = $dtd->getDocumentElement->getAttribute('title'); |
| 2624 |
my $entfile = $config{"expanded-entity-index"}; |
| 2625 |
my $elemfile = $config{"expanded-element-index"}; |
| 2626 |
my $notfile = $config{"notation-index"}; |
| 2627 |
my $root = $dtd->getDocumentElement(); |
| 2628 |
my $elements = $root->getElementsByTagName('element'); |
| 2629 |
my $entities = $root->getElementsByTagName('entity'); |
| 2630 |
my $notations = $root->getElementsByTagName('notation'); |
| 2631 |
my $elemcount = $elements->getLength(); |
| 2632 |
my $entcount = $entities->getLength(); |
| 2633 |
my $notcount = $notations->getLength(); |
| 2634 |
local (*F, $_); |
| 2635 |
|
| 2636 |
return; |
| 2637 |
|
| 2638 |
open (F, ">" . $basedir . "/" . $config{'home'}); |
| 2639 |
|
| 2640 |
print F "<HTML>\n<HEAD>\n<TITLE>$title</TITLE>\n"; |
| 2641 |
print F "</HEAD>\n<BODY>\n"; |
| 2642 |
|
| 2643 |
print F "<H1>$title</h1>\n"; |
| 2644 |
|
| 2645 |
print F "[<A HREF=\"$elemfile\">Elements</A>]\n"; |
| 2646 |
print F "[<A HREF=\"$entfile\">Entities</A>]\n"; |
| 2647 |
print F "[<A HREF=\"$notfile\">Notations</A>]\n"; |
| 2648 |
|
| 2649 |
print F "<HR>\n"; |
| 2650 |
|
| 2651 |
print F "<P>"; |
| 2652 |
print F "The $title "; |
| 2653 |
print F "DTD " if $title !~ / DTD$/i; |
| 2654 |
print F "is composed of $elemcount elements, "; |
| 2655 |
|
| 2656 |
if ($entcount == 0) { |
| 2657 |
print F "no entities, "; |
| 2658 |
} elsif ($entcount == 1) { |
| 2659 |
print F "1 entity, "; |
| 2660 |
} else { |
| 2661 |
print F "$entcount entities, "; |
| 2662 |
} |
| 2663 |
|
| 2664 |
print F "and "; |
| 2665 |
|
| 2666 |
if ($notcount == 0) { |
| 2667 |
print F "no notations.\n"; |
| 2668 |
} elsif ($notcount == 1) { |
| 2669 |
print F "1 notation.\n"; |
| 2670 |
} else { |
| 2671 |
print F "$notcount notations.\n"; |
| 2672 |
} |
| 2673 |
|
| 2674 |
my %etypes = (); |
| 2675 |
for (my $count = 0; $count < $entities->getLength(); $count++) { |
| 2676 |
my $ent = $entities->item($count); |
| 2677 |
my $type = &entityType($ent); |
| 2678 |
$etypes{$type} = 0 if !exists($etypes{$type}); |
| 2679 |
$etypes{$type}++; |
| 2680 |
} |
| 2681 |
|
| 2682 |
print F "<UL COMPACT>\n"; |
| 2683 |
print F "<LI>$elemcount elements\n"; |
| 2684 |
print F "<LI>$entcount ", $entcount == 1 ? "entity" : "entities\n"; |
| 2685 |
|
| 2686 |
print F "<UL COMPACT>\n"; |
| 2687 |
print F ("<LI>", $etypes{'param'}, " parameter ", |
| 2688 |
$etypes{'param'} == 1 ? "entity" : "entities", "\n") |
| 2689 |
if $etypes{'param'} > 0; |
| 2690 |
print F ("<LI>", $etypes{'paramext'}, " external ", |
| 2691 |
$etypes{'paramext'} == 1 ? "entity" : "entities", "\n") |
| 2692 |
if $etypes{'paramext'} > 0; |
| 2693 |
print F ("<LI>", $etypes{'sdata'}, " SDATA ", |
| 2694 |
$etypes{'sdata'} == 1 ? "entity" : "entities", "\n") |
| 2695 |
if $etypes{'sdata'} > 0; |
| 2696 |
print F ("<LI>", $etypes{'charent'}, " character ", |
| 2697 |
$etypes{'charent'} == 1 ? "entity" : "entities", "\n") |
| 2698 |
if $etypes{'charent'} > 0; |
| 2699 |
print F ("<LI>", $etypes{'msparam'}, " Marked section ", |
| 2700 |
$etypes{'msparam'} == 1 ? "entity" : "entities", "\n") |
| 2701 |
if $etypes{'msparam'} > 0; |
| 2702 |
print F ("<LI>", $etypes{'gen'}, " general ", |
| 2703 |
$etypes{'gen'} == 1 ? "entity" : "entities", "\n") |
| 2704 |
if $etypes{'gen'} > 0; |
| 2705 |
print F "</UL>\n"; |
| 2706 |
|
| 2707 |
print F "<LI>$notcount ", $notcount == 1 ? "notation" : "notations\n"; |
| 2708 |
print F "</UL>\n"; |
| 2709 |
|
| 2710 |
print F "It "; |
| 2711 |
if ($root->getAttribute('public-id')) { |
| 2712 |
print F "has the public identifier \""; |
| 2713 |
print F $root->getAttribute('public-id'); |
| 2714 |
print F "\" and "; |
| 2715 |
} |
| 2716 |
|
| 2717 |
print F "claims to be an "; |
| 2718 |
if ($root->getAttribute('xml')) { |
| 2719 |
print F "XML"; |
| 2720 |
} else { |
| 2721 |
print F "SGML"; |
| 2722 |
} |
| 2723 |
print F " DTD. Element "; |
| 2724 |
print F "and notation " if $notcount > 0; |
| 2725 |
print F "names are "; |
| 2726 |
print F "not " if $root->getAttribute('namecase-general'); |
| 2727 |
print F "case sensitive. Entity names are "; |
| 2728 |
print F "not " if $root->getAttribute('namecase-entity'); |
| 2729 |
print F "case sensitive.\n"; |
| 2730 |
print F "</P>\n"; |
| 2731 |
|
| 2732 |
print F "<HR>\n"; |
| 2733 |
print F "HTML Presentation of "; |
| 2734 |
print F $dtd->getDocumentElement->getAttribute('title'); |
| 2735 |
print F " by <A HREF=\"http://www.sf.net/projects/dtdparse/\">"; |
| 2736 |
print F "DTDParse</A>\n"; |
| 2737 |
print F "</BODY>\n"; |
| 2738 |
print F "</HTML>\n"; |
| 2739 |
|
| 2740 |
close (F); |
| 2741 |
} |
| 2742 |
|
| 2743 |
1; |