diff options
author | ville <ville@localhost> | 2010-04-22 18:54:14 +0000 |
---|---|---|
committer | ville <ville@localhost> | 2010-04-22 18:54:14 +0000 |
commit | 8c8a507a9db1573dff499b61122f352153fb12ab (patch) | |
tree | 525ba2133a14fd15d717f02c4fd068c8b18f029d | |
parent | 586614b216f6f2be31dc8220793316e6d1ff386b (diff) | |
download | markup-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-- | Makefile | 4 | ||||
-rwxr-xr-x | misc/soc2xml.pl | 36 |
2 files changed, 38 insertions, 2 deletions
@@ -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/&/ä/g; + $esc =~ s/"/"/g; + $esc =~ s/'/'/g; + $esc =~ s/</</g; + $esc =~ s/>/>/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 |