summaryrefslogtreecommitdiffstats
path: root/misc
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 /misc
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.
Diffstat (limited to 'misc')
-rwxr-xr-xmisc/soc2xml.pl36
1 files changed, 36 insertions, 0 deletions
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