docs-common/bin xmldiff, NONE, 1.1 xmldiff.pl, NONE, 1.1 xmlpp, NONE, 1.1

Tommy Reynolds (jtr) fedora-docs-commits at redhat.com
Thu Dec 15 03:20:04 UTC 2005


Author: jtr

Update of /cvs/docs/docs-common/bin
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv565

Added Files:
	xmldiff xmldiff.pl xmlpp 
Log Message:
Here is a very simple XMLDIFF tool that I've hacked to work reasonably
with the FDP files.  Look in the "xmldiff.pl" file for information about
its origin.



--- NEW FILE xmldiff ---
#!/bin/sh
export PATH=`dirname $0`:${PATH}
exec perl `basename $0`.pl $@


--- NEW FILE xmldiff.pl ---
#!/usr/bin/perl
#
#  Copyright (c) 2002, DecisionSoft Limited All rights reserved.
#  Please see: 
#  http://software.decisionsoft.com/licence.html 
#  for more information.
#
# Modified for the Fedora Docs Project by Tommy.Reynolds at MegaCoder.com
# 

#
# xmldiff: xmldiff program - uses xmlpp, which must be on the ${PATH}
#

#Change this if xmlpp is not in your current path
#for example: $XMLPP = "./xmlpp";
$XMLPP = "xmlpp";

use Getopt::Std;

getopts('tscupChHSi');

if ($opt_h || @ARGV != 2) {
	usage();
}

my $diffOpts;

my $outputFmt = $opt_u + $opt_c + $opt_s + $opt_p + $opt_C;
if( $outputFmt == 0 )	{
	$outputFmt = $opt_p = 1;
}
if( $outputFmt > 1 )	{
  print STDERR "Error: Only one mode may be specified\n";
  usage();
}

if( $opt_s )	{
	# Standard diff, no playing around
} 
if ( $opt_c )	{
	# Plain context diff
	$diffOpts .= "-c ";
} 
if( $opt_u )	{
	# Plain unified diff
	$diffOpts .= "-u ";
} 
if( $opt_p )	{
	# Colorized unified diff
	# $diffOpts .= "-u ";
	$diffOpts .= "--new-line-format='+ %l\n' ";
	$diffOpts .= "--old-line-format='- %l\n' ";
	$diffOpts .= "--unchanged-line-format='  %l\n' ";
} 
if( $opt_C )	{
  $diffOpts .= "--changed-group-format='\n<<<<<<<<<<<<<<\n%<==============\n%>>>>>>>>>>>>>>>\n\n' ";
  $diffOpts .= "--new-line-format='+ %l\n' ";
  $diffOpts .= "--old-line-format='- %l\n' ";
  $diffOpts .= "--unchanged-line-format='  %l\n' ";
} 
if( $opt_H )	{
  $diffOpts .= "--changed-group-format='%<%>' ";
  $diffOpts .= " --new-group-format='%>' ";
  $diffOpts .= "--old-group-format='%<' ";
  $diffOpts .= "--new-line-format='<font color=\"green\">+ %l</font>\n' ";
  $diffOpts .= "--old-line-format='<font color=\"red\">- %l</font>\n' ";
  $diffOpts .= "--unchanged-line-format='<font color=\"gray\">  %l</font>\n' ";
}

# Set up xmlpp options

my $prettyOpts = $opt_t ? "-t " : "";
$prettyOpts   .= $opt_S ? "-S " : "";
$prettyOpts   .= $opt_H ? "-H " : "";
$prettyOpts   .= "-s -e ";

$file1 = "xmlppTEMP1.$$";
$file2 = "xmlppTEMP2.$$";

my $results = 0;
$results += system("$XMLPP $prettyOpts '$ARGV[0]' > $file1");
$results += system("$XMLPP $prettyOpts '$ARGV[1]' > $file2");

if($opt_H) {
	print "<HTML>\n";
	print "  <HEAD>\n";
	print "    <TITLE>XML Diff</TITLE>\n";
	print "  </HEAD>\n";
	print "  <BODY bgcolor=\"#FEFEFF\">\n";
	print "    <PRE>";
	$results += system("/usr/bin/diff -bB $diffOpts $file1 $file2");
	# Do not add extra whitespace before the </PRE>
	print "</PRE>\n";
	print "  </BODY>\n";
	print "</HTML>\n";

} else {
	$results += system("/usr/bin/diff -bB $diffOpts $file1 $file2");
}


unlink($file1,$file2);

exit( $results );

sub usage {
  print STDERR <<EOF;
usage: $0 [ mode ] [ options ] oldfile.xml newfile.xml

mode must be one of:
  -p  coloured unified diff [default]
  -c  context diff
  -u  unified diff
  -s  standard diff output
  -C  vaguely CVS like unified diff

options:
  -H  HTML output
  -t  split attributes - good for spotting changes in attributes
  -S  schema hack mode - good for diffing schemas
  -i  ignore element and attribute contents

EOF
  exit 1;
}


***** Error reading new file: [Errno 2] No such file or directory: 'xmlpp'




More information about the Fedora-docs-commits mailing list