| 2 |
## $Id$ |
## $Id$ |
| 3 |
## ------------------------------------------------------------------------ |
## ------------------------------------------------------------------------ |
| 4 |
## $Log$ |
## $Log$ |
| 5 |
|
## Revision 1.5 2003/12/05 04:52:40 joko |
| 6 |
|
## + minor update: changed some loglevel to debug |
| 7 |
|
## |
| 8 |
|
## Revision 1.4 2003/06/06 03:58:13 joko |
| 9 |
|
## minor updates to logging |
| 10 |
|
## |
| 11 |
## Revision 1.3 2003/05/13 08:08:17 joko |
## Revision 1.3 2003/05/13 08:08:17 joko |
| 12 |
## comments, todos |
## comments, todos |
| 13 |
## |
## |
| 31 |
); |
); |
| 32 |
|
|
| 33 |
|
|
| 34 |
|
# TODO: Load them on demand! |
| 35 |
use Data::Dumper; |
use Data::Dumper; |
| 36 |
#use Data::Storage::Handler::File::Basic qw( s2f a2f f2s ); |
#use Data::Storage::Handler::File::Basic qw( s2f a2f f2s ); |
| 37 |
use XML::Simple; |
use XML::Simple; |
| 40 |
use XML::XPath; |
use XML::XPath; |
| 41 |
# TODO: use XML::Writer and/or XML::ValidWriter |
# TODO: use XML::Writer and/or XML::ValidWriter |
| 42 |
|
|
| 43 |
|
|
| 44 |
|
# get logger instance |
| 45 |
|
my $logger = Log::Dispatch::Config->instance; |
| 46 |
|
|
| 47 |
sub sendQuery { |
sub sendQuery { |
| 48 |
my $self = shift; |
my $self = shift; |
| 49 |
my $xpq = shift; |
my $xpq = shift; |
| 58 |
my $file = $self->{filename}; |
my $file = $self->{filename}; |
| 59 |
|
|
| 60 |
if (!$file) { |
if (!$file) { |
| 61 |
$self->log("No filename given.", 'error'); |
$logger->error("No filename given."); |
| 62 |
return; |
return; |
| 63 |
} |
} |
| 64 |
|
|
| 65 |
if (! -e $file) { |
if (! -e $file) { |
| 66 |
$self->log("File not found: '$file'.", 'error'); |
$logger->error("File not found: '$file'."); |
| 67 |
return; |
return; |
| 68 |
} |
} |
| 69 |
|
|
| 70 |
#print "file: $file", "\n"; |
#print "file: $file", "\n"; |
| 71 |
#print "xpq: $xpq", "\n"; |
#print "xpq: $xpq", "\n"; |
| 72 |
|
|
| 73 |
|
$logger->debug( __PACKAGE__ . "->sendQuery - File: $file, xpq: $xpq"); |
| 74 |
|
|
| 75 |
# filter nodes by xpath-query |
# filter nodes by xpath-query |
| 76 |
my $xp = XML::XPath->new( filename => $file ); |
my $xp = XML::XPath->new( filename => $file ); |
| 77 |
my $nodeset = $xp->find($xpq); |
my $nodeset = $xp->find($xpq); |