/[papo]/papo/xot/Xot.pm
ViewVC logotype

Diff of /papo/xot/Xot.pm

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

revision 1.1 by jlenton, Mon May 19 19:06:08 2003 UTC revision 1.2 by jlenton, Mon Jun 30 03:42:06 2003 UTC
# Line 2  package Xot; Line 2  package Xot;
2  use strict;  use strict;
3  use XML::Twig;  use XML::Twig;
4  use Xot::Table;  use Xot::Table;
5    use Xot::Style::Defs;
6    use base qw(Xot::Accessors);
7    
8  sub new  Xot->plain(qw(file));
9  {  Xot->multi('table' => 'Xot::Table',
10      my $class = shift;            );
     my $self = bless {}, $class;  
   
     $self->init(@_);  
   
     return $self;  
 }  
11    
12  sub init  sub init
13  {  {
14      my $self = shift;      my $self = shift;
15      my $file = shift;      my $file = shift;
16    
17      $self->{TWIG} = XML::Twig->new(      $self->twig(XML::Twig->new(
18          twig_handlers => { 'table' => sub { $self->add_table($_) },          twig_handlers => { 'table' => sub { $self->add_table($_) },
19                               'style_definitions' => sub { $self->style_defs($_) },
20                           },                           },
21          pretty_print => 'indented'          pretty_print => 'indented'
22      );      ));
23    
24      if (defined $file)      if (defined $file)
25      {      {
26          $self->file($file);          $self->file($file);
27          $self->twig->parsefile($file);          $self->twig->parsefile($file);
28    #        $self->merge_references;
29      }      }
30  }  }
31    
 sub file  
 {  
     my $self = shift;  
     my $file = shift;  
   
     $self->{FILE} = $file  
         if defined $file;  
   
     return $self->{FILE};  
 }  
   
 sub twig  
 {  
     my $self = shift;  
   
     return $self->{TWIG}  
 }  
   
 sub table  
 {  
     my $self = shift;  
     my $name = shift;  
     my $table = shift;  
   
     die "must call table with a table name"  
         unless $name;  
   
     $self->{TABLES}->{$name} = $table  
         if defined $table;  
   
     return $self->{TABLES}->{$name}  
 }  
   
 sub tables  
 {  
     my $self = shift;  
   
     return keys %{ $self->{TABLES} || {} };  
 }  
   
 sub add_table  
 {  
     my $self = shift;  
     my $twig = shift;  
   
     die "must call add_table with a twig"  
         unless defined $twig;  
   
     my $name = $twig->att("name");  
     my $table = Xot::Table->new($twig);  
     $self->table($name => $table);  
 }  
   
   
32  1;  1;

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

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26