--- nfo/perl/libs/Data/Storage/Handler/XML.pm 2003/02/20 20:20:54 1.1 +++ nfo/perl/libs/Data/Storage/Handler/XML.pm 2003/12/05 04:52:40 1.5 @@ -1,7 +1,19 @@ ## ------------------------------------------------------------------------ -## $Id: XML.pm,v 1.1 2003/02/20 20:20:54 joko Exp $ +## $Id: XML.pm,v 1.5 2003/12/05 04:52:40 joko Exp $ ## ------------------------------------------------------------------------ ## $Log: XML.pm,v $ +## Revision 1.5 2003/12/05 04:52:40 joko +## + minor update: changed some loglevel to debug +## +## Revision 1.4 2003/06/06 03:58:13 joko +## minor updates to logging +## +## Revision 1.3 2003/05/13 08:08:17 joko +## comments, todos +## +## Revision 1.2 2003/02/21 07:58:48 joko +## enhanced error detection +## ## Revision 1.1 2003/02/20 20:20:54 joko ## + initial commit ## @@ -19,20 +31,25 @@ ); +# TODO: Load them on demand! use Data::Dumper; #use Data::Storage::Handler::File::Basic qw( s2f a2f f2s ); use XML::Simple; use XML::Parser; use XML::Parser::EasyTree; use XML::XPath; +# TODO: use XML::Writer and/or XML::ValidWriter + +# get logger instance +my $logger = Log::Dispatch::Config->instance; sub sendQuery { my $self = shift; my $xpq = shift; my $options = shift; - $self->log( "xpq='$xpq'", 'info' ); + $self->log( "xpq='$xpq'", 'debug' ); # trace #print Dumper($self); @@ -40,14 +57,21 @@ my $file = $self->{filename}; + if (!$file) { + $logger->error("No filename given."); + return; + } + if (! -e $file) { - $self->log("File not found: '$file'.", 'error'); + $logger->error("File not found: '$file'."); return; } #print "file: $file", "\n"; #print "xpq: $xpq", "\n"; - + + $logger->debug( __PACKAGE__ . "->sendQuery - File: $file, xpq: $xpq"); + # filter nodes by xpath-query my $xp = XML::XPath->new( filename => $file ); my $nodeset = $xp->find($xpq); @@ -89,6 +113,11 @@ my $self = shift; $XML::Parser::EasyTree::Noempty = 1; + # what about ... + #$XML::Parser::EasyTree::Latin = 1; + # ... instead of an otherwise required + # "expand" with proper utf8/latin-conversion + # parameters set? # convert xml data to native perl data structure #my $parser = XML::Parser->new( Style => 'EasyTree', Handlers => { Char => sub { my $char = shift; print "char: ", Dumper($char), "\n"; } } );