W3C home > Mailing lists > Public > www-validator-cvs@w3.org > April 2010

validator/misc soc2xml.pl,NONE,1.1

From: Ville Skytta via cvs-syncmail <cvsmail@w3.org>
Date: Thu, 22 Apr 2010 18:54:16 +0000
To: www-validator-cvs@w3.org
Message-Id: <E1O51XU-0002Rx-Ha@lionel-hutz.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/&/&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
Received on Thursday, 22 April 2010 18:54:19 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Thursday, 26 April 2012 12:55:20 GMT