#!/usr/bin/perl -- # -*- Perl -*- # This script attempts to replace external parsed entities with # XInclude elements. use strict; use English; my $usage = "$0 input.xml\n"; my $file = shift @ARGV || die $usage; die $usage unless -f $file; my %epe = (); open (F, $file); read (F, $_, -s $file); close (F); if (/^<\?xml\s.*?\?>\s*/) { print $MATCH; $_ = $POSTMATCH; } my $body = ""; if (/^]+\[/s) { print $MATCH; $_ = $POSTMATCH; if (/^(.*?)\]/s) { print $MATCH; $body = $POSTMATCH; $_ = $1; while (/^\s*(<.*?>)/s) { my $decl = $1; $_ = $POSTMATCH; if ($decl =~ /"; } else { print "&$2;"; } $body = $POSTMATCH; } print $body;