#!\c:\apps\perl\bin\perl.exe

#Create a valid xml charent file from the characters in 
#the charmap.sgm file.

#MAKES ENT FILE WITH VIEWABLE ENTITIES, NOT PRIVATE USE CHARACTERS

#use strict;

#include tcp character map subroutines
require "C:/code/Perl/Eebo/tcp-charmap-include.pm";

#file containing character map
my $charactermap = "C:/code/charents/charmap.sgm"; 

#put character map into a perl array
charmap_array($charactermap); 

#create xml ent file

print "<!-- XML character entities -->\n\n";
print "<!-- Generated by tcp-charmap-entmake-xml-all-view.pl on " . localtime(time) . " -->\n\n";

foreach $entity (@entities) {
   my $view;
   my $ent = content_attr('ENT','TCP');
   my $comment = join(" ",content_attr('EQUIV','DESC'), content_tag("COMMENT"));
      
   #use Arial Unicode MS entity
   $view = content_attr_known('REPL','TXT','SUP','Arial Unicode MS');
   #if no Arial entry, use default entity
   if (! $view) {
      $view = content_attr_known('REPL','TXT','SUP','default');
   }
   #if ($view =~ m,&\#x([^;]*?);,) {
   #   $view = $1;
   #}
   
   #TODO check for multiple EQUIV and COMMENT tags
   print "<!ENTITY $ent \"$view\"> <!--$comment-->\n";
}

print "\n";   
