#!/usr/bin/perl
=head1 NAME
xacobeo - Graphical interface for running XPath queries.
=head1 SYNOPSIS
xacobeo [OPTION]... [file [xpath]]
Options:
-h, --help brief help message
-v, --version display the version of Xacobeo, XML::LibXML and libxml2
that are used and exit
--html parse the input file as an HTML document
Where I<file> is a XML document and I<xpath> a XPath query.
=head1 OPTIONS
=over 8
=item B<--help>
Print a brief help message and exits.
=item B<--html>
Parse the file in the command line using the HTML parser.
=back
=head1 DESCRIPTION
This program provides a simple graphical user interface (GUI) for executing
XPath queries and seeing their results.
The GUI tries to provide all the elements that are needed in order to write,
test and execute XPath queries without too many troubles. It displays the
Document Object Model (DOM) and the namespaces used. The program registers the
namespaces automatically and each element is displayed with its associated
namespaces. All is performed with the idea of being able of running an XPath
query as soon as possible without having to fight with the document's namespaces
and by seeing automatically under which namespace each element is.
This program is not an XML editor, at least not at this point, it's meant to be
used for constructing and executing XPath queries.
=head1 RATIONALE
The main idea behind this application is to provide a simple way for building
XPath queries that will be latter integrated in to a program or XSLT
transformation paths. Therefore, this program goal is to load an XML document
and to display it as an XML parser sees it. Thus each node element is prefixed
with its namespace.
=head1 IMPLEMENTATION
This program uses L<XML::LibXML> (libxml2) for all XML manipulations and L<Gtk2>
for the graphical interface.
=head1 LIMITATIONS
For the moment, the program focuses only on XPath and doesn't allow the XML
document to be edited.
=head1 AUTHOR
Emmanuel Rodriguez E<lt>potyl@cpan.orgE<gt>.
=head1 COPYRIGHT AND LICENSE
Copyright (C) 2008,2009 by Emmanuel Rodriguez.
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself, either Perl version 5.8.8 or,
at your option, any later version of Perl 5 you may have available.
=cut
use strict;
use warnings;
use open qw(:std :utf8);
use Glib qw(TRUE FALSE);
use Gtk2 qw(-init);
use Pod::Usage;
use Getopt::Long qw(:config auto_help);
use XML::LibXML;
use Xacobeo;
use Xacobeo::App;
exit main() unless caller;
#
# Main entry point of the program
#
sub main {
# Parse the command line options
my $type = 'xml';
my $do_version = 0;
GetOptions(
'html' => sub { $type = 'html' },
'version|v' => \$do_version,
) or pod2usage(2);
if ($do_version) {
printf "Xacobeo version: %8s\n", $Xacobeo::VERSION;
printf "Compiled with libxml: %8s\n", XML::LibXML::LIBXML_DOTTED_VERSION;
printf "Running with libxml: %8s\n", XML::LibXML::LIBXML_RUNTIME_VERSION;
printf "XML::LibXML version: %8s\n", $XML::LibXML::VERSION;
return 0;
}
# Create a new instance of this application
my $xacobeo = Xacobeo::App->get_app();
# Create the first window
my $window = $xacobeo->new_window();
if (@ARGV) {
my ($source, $xpath) = @ARGV;
$window->load_file($source, $type);
$window->set_xpath($xpath) if defined $xpath;
}
$xacobeo->load_plugins();
# Start the main loop
Gtk2->main();
return 0;
}