summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorville <ville@localhost>2010-04-22 18:54:14 +0000
committerville <ville@localhost>2010-04-22 18:54:14 +0000
commit8c8a507a9db1573dff499b61122f352153fb12ab (patch)
tree525ba2133a14fd15d717f02c4fd068c8b18f029d
parent586614b216f6f2be31dc8220793316e6d1ff386b (diff)
downloadmarkup-validator-8c8a507a9db1573dff499b61122f352153fb12ab.zip
markup-validator-8c8a507a9db1573dff499b61122f352153fb12ab.tar.gz
markup-validator-8c8a507a9db1573dff499b61122f352153fb12ab.tar.bz2
Add crude script for converting SGML Open Catalogs to XML catalogs.
-rw-r--r--Makefile4
-rwxr-xr-xmisc/soc2xml.pl36
2 files changed, 38 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index 1e9d39c..fe64a9f 100644
--- a/Makefile
+++ b/Makefile
@@ -1,8 +1,8 @@
VERSION = $(shell perl -ne '/^version:\s*(\S+)/ && print $$1' misc/bundle/META.yml)
PERL_FILES = httpd/cgi-bin/check httpd/cgi-bin/sendfeedback.pl \
- misc/spmpp.pl misc/docs_errors.pl misc/bundle/Makefile.PL \
- misc/bundle/lib/Bundle/W3C/Validator.pm
+ misc/soc2xml.pl misc/spmpp.pl misc/docs_errors.pl \
+ misc/bundle/Makefile.PL misc/bundle/lib/Bundle/W3C/Validator.pm
PERLTIDY = perltidy --profile=misc/perltidyrc --backup-and-modify-in-place
PERLCRITIC = perlcritic --profile misc/perlcriticrc
diff --git a/misc/soc2xml.pl b/misc/soc2xml.pl
new file mode 100755
index 0000000..83d005a
--- /dev/null
+++ b/misc/soc2xml.pl
@@ -0,0 +1,36 @@
+#!/usr/bin/perl -w
+
+use strict;
+
+# Crude script for converting SGML Open Catalogs to XML catalogs.
+# Usage: soc2xml.pl < catalog.soc > catalog.xml
+
+sub esc
+{
+ (my $esc = shift) =~ s/&/&auml;/g;
+ $esc =~ s/"/&quot;/g;
+ $esc =~ s/'/&apos;/g;
+ $esc =~ s/</&lt;/g;
+ $esc =~ s/>/&gt;/g;
+ $esc;
+}
+
+$/ = undef;
+my $soc = <STDIN>;
+
+print <<'EOF';
+<?xml version="1.0"?>
+<!DOCTYPE catalog PUBLIC "-//OASIS//DTD Entity Resolution XML Catalog V1.0//EN" "http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd">
+<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
+EOF
+
+while ($soc =~ /(PUBLIC|SYSTEM)\s+"([^"]+)"\s+"([^"]+)"/g) {
+ my $pubsys = lc($1);
+ printf <<'EOF', $pubsys, $pubsys, esc($2), esc($3);
+ <%s %sId="%s" uri="%s" />
+EOF
+}
+
+print <<'EOF';
+</catalog>
+EOF