- From: Ville Skytta via cvs-syncmail <cvsmail@w3.org>
- Date: Thu, 22 Apr 2010 18:54:16 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/validator/misc
In directory hutz:/tmp/cvs-serv9376/misc
Added Files:
soc2xml.pl
Log Message:
Add crude script for converting SGML Open Catalogs to XML catalogs.
--- NEW FILE: soc2xml.pl ---
#!/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
Received on Thursday, 22 April 2010 18:54:19 UTC