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

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

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

revision 1.1 by joko, Fri Apr 18 17:20:21 2003 UTC revision 1.2 by joko, Tue May 13 08:02:13 2003 UTC
# Line 2  Line 2 
2  ##  $Id$  ##  $Id$
3  ## -------------------------------------------------------------------------  ## -------------------------------------------------------------------------
4  ##  $Log$  ##  $Log$
5    ##  Revision 1.2  2003/05/13 08:02:13  joko
6    ##  removed xml stuff
7    ##
8  ##  Revision 1.1  2003/04/18 17:20:21  joko  ##  Revision 1.1  2003/04/18 17:20:21  joko
9  ##  intial commit  ##  intial commit
10  ##  ##
11  ## -------------------------------------------------------------------------  ## -------------------------------------------------------------------------
12    
13    
14    =pod
15    
16    =head1 DESCRIPTION
17    
18      Should handle primitives (scalar, HASH, ARRAY) transparently.
19      After that: Enhance to FILEHANDLE and/or OBJECT.
20      
21    
22    =cut
23    
24    
25  package Data::Storage::Handler::AutoSymbol;  package Data::Storage::Handler::AutoSymbol;
26    
27  use strict;  use strict;
# Line 21  use base qw( Line 35  use base qw(
35    
36    
37  use Data::Dumper;  use Data::Dumper;
38    use Data::Storage::Result::Hash;
39    
40    
41  sub sendQuery_tmp {  sub getChildNodes {
42    my $self = shift;    my $self = shift;
   my $xpq = shift;  
   my $options = shift;  
43    
44    $self->log( "xpq='$xpq'", 'debug' );    my $storage = $self->{reference};
45    
46    # trace    my $nodes;
47      #print Dumper($self);    if (not ref $storage) {
48      #exit;      $nodes = [ $storage ];
49      } elsif (ref $storage eq 'HASH') {
50    my $file = $self->{filename};      $nodes = [ sort keys %$storage ];
     
   if (!$file) {  
     $self->log("No filename given.", 'error');  
     return;  
51    }    }
52        
53    if (! -e $file) {    return $nodes;
     $self->log("File not found: '$file'.", 'error');  
     return;  
   }  
54    
55    #print "file: $file", "\n";  }
56    #print "xpq: $xpq", "\n";  
57      sub sendQuery {
58    # filter nodes by xpath-query    my $self = shift;
59      my $xp = XML::XPath->new( filename => $file );    my $query = shift;
60      my $nodeset = $xp->find($xpq);    my $options = shift;
61    
62      #print "query: ", Dumper($query);
63        
64    # build result xml    my $slot;
65      my $buffer;    # by list
66      foreach my $node ($nodeset->get_nodelist) {    #$slot = $query->{node};
67        $buffer .= XML::XPath::XMLParser::as_string($node) . "\n\n";    # by item
68      $slot = $query->{options}->{GUID};
69    
70      my $storage = $self->{reference};
71    
72      my $payload;
73      if (not ref $storage) {
74        $payload = $storage;
75      } elsif (ref $storage eq 'HASH') {
76        if ($slot) {
77          # TODO: enhance using ref_slot
78          $payload = $storage->{$slot};
79        } else {
80          $payload = $storage;
81      }      }
82      #$buffer .= '';    }
83      #$buffer = "<result>$buffer</result>";  
84        #print "payload: ", Dumper($payload);
85    # trace    #return;
     #print $buffer, "\n";  
     #exit;  
86    
87    $self->{buffer} = $buffer;    if ($payload) {
88        my $result = Data::Storage::Result::Hash->new( RESULTHANDLE => $payload );
89        return $result;
90      }
91        
92  }  }
93    
# Line 79  sub isEmpty_tmp { Line 101  sub isEmpty_tmp {
101    return not defined $self->{buffer};    return not defined $self->{buffer};
102  }  }
103    
 sub getChildNodes {  
   my $self = shift;  
   
   my $storage = $self->{storage};  
   
   my $nodes;  
   if (not ref $storage) {  
     $nodes = [ $storage ];  
   } elsif (ref $storage eq 'HASH') {  
     $nodes = [ sort keys %$storage ];  
   }  
     
   return $nodes;  
   
 }  
104    
105  1;  1;
106  __END__  __END__

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

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