SGML-DTDParse

 view release on metacpan or  search on metacpan

bin/dtdflatten  view on Meta::CPAN


		print $out_fh "<!ENTITY % $name $quote$text$quote>\n";
	    }
	}
    } elsif ($decl->type() eq 'gen') {
	my $name = $decl->name();
	my $public = $decl->public();
	my $system = $decl->system();

	if ($public || $system) {
	    print $out_fh "<!ENTITY $name ";

	    if ($public) {
		my $quote = '"';
		if ($public =~ /\"/s) {
		    $quote = "'";
		    $public =~ s/\'/\&apos;/sg;
		}
		print $out_fh "PUBLIC $quote$public$quote";
	    }

	    if ($system) {
		my $quote = '"';
		if ($system =~ /\"/s) {
		    $quote = "'";
		    $system =~ s/\'/\&apos;/sg;
		}
		print $out_fh "SYSTEM" if !$public;
		print $out_fh " $quote$system$quote";
	    }

	    print $out_fh ">\n";
	} else {
	    my $text = $decl->text();
	    $text = &expandPE($text);

	    my $quote = '"';
	    if ($text =~ /\"/s) {
		$quote = "'";
		$text =~ s/\'/\&apos;/sg;
	    }
	    print $out_fh "<!ENTITY $name $quote$text$quote>\n";
	}
    } elsif ($decl->type() eq 'sdata'
	     || $decl->type() eq 'pi') {
	my $name = $decl->name();

	print $out_fh "<!ENTITY $name " . uc($decl->type()) . " ";

	my $text = $decl->text();
	$text = &expandPE($text);

	my $quote = '"';
	if ($text =~ /\"/s) {
	    $quote = "'";
	    $text =~ s/\'/\&apos;/sg;
	}

	print $out_fh "$quote$text$quote>\n";
    } elsif ($decl->type() eq 'ndata'
	     || $decl->type() eq 'cdata') {
	my $name = $decl->name();
	my $public = $decl->public();
	my $system = $decl->system();

	print $out_fh "<!ENTITY $name ";

	if ($public) {
	    my $quote = '"';
	    if ($public =~ /\"/s) {
		$quote = "'";
		$public =~ s/\'/\&apos;/sg;
	    }
	    print $out_fh "PUBLIC $quote$public$quote";
	}

	if ($system) {
	    my $quote = '"';
	    if ($system =~ /\"/s) {
		$quote = "'";
		$system =~ s/\'/\&apos;/sg;
	    }
	    print $out_fh "SYSTEM" if !$public;
	    print $out_fh " $quote$system$quote";
	}

	print $out_fh " ", uc($decl->type()), " ", $decl->notation();
	print $out_fh ">\n";
    } elsif ($decl->type() eq 'notation') {
	my $name = $decl->name();
	my $public = $decl->public();
	my $system = $decl->system();

	print $out_fh "<!NOTATION $name ";

	if ($public) {
	    my $quote = '"';
	    if ($public =~ /\"/s) {
		$quote = "'";
		$public =~ s/\'/\&apos;/sg;
	    }
	    print $out_fh "PUBLIC $quote$public$quote";
	}

	if ($system) {
	    my $quote = '"';
	    if ($system =~ /\"/s) {
		$quote = "'";
		$system =~ s/\'/\&apos;/sg;
	    }
	    print $out_fh "SYSTEM" if !$public;
	    print $out_fh " $quote$system$quote";
	}

	if (!$public && !$system) {
	    print $out_fh "SYSTEM";
	}

	print $out_fh ">\n";
    } else {
	die "Error: Unexpected declaration type: " . $decl->type() . "\n";



( run in 1.285 second using v1.01-cache-2.11-cpan-39bf76dae61 )