Usage:
make_entities.pl <prefix> <filename> > filename.new 2> entities.dtd
mv filename.new filename
sort entities.dtd | uniq >> lang.dtd
git-svn-id: svn://svn.open-ils.org/ILS/trunk@14264
dcc99617-32d9-48b4-a31d-
7c20da2025e4
--- /dev/null
+#!/usr/bin/perl -w
+
+use strict;
+
+my $entity_prefix = $ARGV[0];
+my $filename = $ARGV[1];
+
+if (! $entity_prefix && ! $filename) {
+ print STDOUT "Usage:\n\tmake_entities.pl <prefix> <filename> > filename.new 2> entities.dtd\n\n\tmv filename.new filename\n\tsort entities.dtd | uniq >> lang.dtd\n\n";
+ exit 0;
+}
+
+my %entity_hash = ();
+
+open FILE, $filename;
+while (my $line = <FILE>) {
+
+ while ($line =~ /(label|value)="(.+?)"/g) {
+ my $value = $2; if ( $value =~ /^&.+;$/ ) { next; } # Already an entity
+ my $entity = $value; $entity =~ s/\W/_/g; $entity = $entity_prefix . $entity;
+ $line =~ s/$value/&$entity;/g;
+ print STDERR qq^<!ENTITY $entity "$value">\n^;
+ }
+ print STDOUT $line;
+
+}
+close FILE;