/[cvs]/nfo/perl/libs/Data/Storage/Handler/XML.pm
ViewVC logotype

Diff of /nfo/perl/libs/Data/Storage/Handler/XML.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by joko, Thu Feb 20 20:20:54 2003 UTC revision 1.4 by joko, Fri Jun 6 03:58:13 2003 UTC
# Line 2  Line 2 
2  ##  $Id$  ##  $Id$
3  ## ------------------------------------------------------------------------  ## ------------------------------------------------------------------------
4  ##  $Log$  ##  $Log$
5    ##  Revision 1.4  2003/06/06 03:58:13  joko
6    ##  minor updates to logging
7    ##
8    ##  Revision 1.3  2003/05/13 08:08:17  joko
9    ##  comments, todos
10    ##
11    ##  Revision 1.2  2003/02/21 07:58:48  joko
12    ##  enhanced error detection
13    ##
14  ##  Revision 1.1  2003/02/20 20:20:54  joko  ##  Revision 1.1  2003/02/20 20:20:54  joko
15  ##  + initial commit  ##  + initial commit
16  ##  ##
# Line 25  use XML::Simple; Line 34  use XML::Simple;
34  use XML::Parser;  use XML::Parser;
35  use XML::Parser::EasyTree;  use XML::Parser::EasyTree;
36  use XML::XPath;  use XML::XPath;
37    # TODO: use XML::Writer and/or XML::ValidWriter
38    
39    
40    # get logger instance
41    my $logger = Log::Dispatch::Config->instance;
42    
43  sub sendQuery {  sub sendQuery {
44    my $self = shift;    my $self = shift;
45    my $xpq = shift;    my $xpq = shift;
46    my $options = shift;    my $options = shift;
47    
48    $self->log( "xpq='$xpq'", 'info' );    $self->log( "xpq='$xpq'", 'debug' );
49    
50    # trace    # trace
51      #print Dumper($self);      #print Dumper($self);
# Line 40  sub sendQuery { Line 53  sub sendQuery {
53    
54    my $file = $self->{filename};    my $file = $self->{filename};
55        
56      if (!$file) {
57        $logger->error("No filename given.");
58        return;
59      }
60      
61    if (! -e $file) {    if (! -e $file) {
62      $self->log("File not found: '$file'.", 'error');      $logger->error("File not found: '$file'.");
63      return;      return;
64    }    }
65    
66    #print "file: $file", "\n";    #print "file: $file", "\n";
67    #print "xpq: $xpq", "\n";    #print "xpq: $xpq", "\n";
68      
69      $logger->info( __PACKAGE__ . "->sendQuery - File: $file, xpq: $xpq");
70    
71    # filter nodes by xpath-query    # filter nodes by xpath-query
72      my $xp = XML::XPath->new( filename => $file );      my $xp = XML::XPath->new( filename => $file );
73      my $nodeset = $xp->find($xpq);      my $nodeset = $xp->find($xpq);
# Line 89  sub toEasyTree { Line 109  sub toEasyTree {
109    my $self = shift;    my $self = shift;
110    
111      $XML::Parser::EasyTree::Noempty = 1;      $XML::Parser::EasyTree::Noempty = 1;
112        # what about ...
113        #$XML::Parser::EasyTree::Latin = 1;
114        # ... instead of an otherwise required
115        # "expand" with proper utf8/latin-conversion
116        # parameters set?
117    
118      # convert xml data to native perl data structure      # convert xml data to native perl data structure
119        #my $parser = XML::Parser->new( Style => 'EasyTree', Handlers => { Char => sub { my $char = shift; print "char: ", Dumper($char), "\n"; } } );        #my $parser = XML::Parser->new( Style => 'EasyTree', Handlers => { Char => sub { my $char = shift; print "char: ", Dumper($char), "\n"; } } );

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.4

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed