#!/usr/bin/perl

#################################################
#  program:     validxml     	                #
#  license:     GPL V2                          #
#  author:      Gavin Henry                     #
#  company:     Suretec Systems Ltd.            #
#  url:         http://www.suretecsystems.com   #
#  version:     v0.1                            #
#                                               #
#  first draft: 07-02-2005                      #
#  last update: 11-05-2005             		#
#				                #
#  Description:			                #
#  Quick hack to validate all our docbook-xml	#
#  stuff. Needs at least one argument           #
#				                #
#################################################

use warnings;
use strict;
use Getopt::Long;
use Pod::Usage;

my $validate = 0;
my $help = 0;
my $man = 0;

GetOptions( "validate=s"   => \$validate,
            "help|2"       => \$help, 
            "man"          => \$man)
or pod2usage(2);
pod2usage(1) if $help;
pod2usage(-verbose => 2) if $man;

if ($validate) {
    print "\nValidating Docbook XML file...\n";
    !system "xmllint --xinclude --loaddtd --noout --postvalid $validate"
	or die "\nNot Valid!!!\n\nPlease review your file.\n\n";
    print "\nLooks good!!\n\nYou can go ahead and generate your docs.\n\n";
    exit 0;
}

## If no arguments were given, then allow STDIN to be used only
## if it's not connected to a terminal (otherwise print usage)
pod2usage("$0: No files given or too many options given.")  if ((@ARGV == 0) || (@ARGV > 1) && (-t STDIN));
__END__

=head1 NAME

validxml - Wrapper for xmllinti, from the xmlto package

=head1 SYNOPSIS

validxml [options] [file ...]

=over 16

=item B<Options:>

=item B<-h, --help>

Print a brief help message and exits.

=item B<-m, --man>

Prints the manual page and exits.

=item B<-v, --validate>

XML file to validate

=back

=head1 OPTIONS

=over 16

=item B<-h, --help>

Print a brief help message and exits.

=item B<-m, --man>

Prints the manual page and exits.

=item B<-v, --validate>

XML file to validate

=back

=head1 DESCRIPTION

B<This program> will read the given input file(s) and then
pass them to xmllint using these parameters:

B<--xinclude --loaddtd --noout --postvalid>

=head1 AUTHOR

Gavin Henry ghenry[AT]suretecsystems.com

B<url:> http://www.suretecsystems.com

=head1 REPORTING BUGS

Please e-mail the author directly or support[AT]suretecsystems.com

=head1 LEGAL

=head2 Copyright

This program is Copyright 2005 by Gavin Henry of
Suretec Systems Ltd.

=head2 License

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at
your option) any later version.

=head2 Disclaimer

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

=head2 More information

If you do not have a copy of the GNU General Public License write to
the Free Software Foundation, Inc., 675 Mass Ave, Cambridge,
MA 02139, USA.

=head1 SEE ALSO

man xmllint

=cut



syntax highlighted by Code2HTML, v. 0.9.1