mach        2003/12/10 14:50:45

  Modified:    lib/Apache/AxKit Tag: axkit-pipeline-2 Pipeline.pm
               lib/Apache/AxKit/Pipeline Tag: axkit-pipeline-2 Cache.pm
                        Head.pm Language.pm LibXSLT.pm SAX.pm Trace.pm
                        Transformer.pm XSP.pm
  Removed:     lib/Apache/AxKit/Pipeline Tag: axkit-pipeline-2 Tail.pm
  Log:
  fixes and api changes
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.1.2.7   +61 -51    xml-axkit/lib/Apache/AxKit/Attic/Pipeline.pm
  
  Index: Pipeline.pm
  ===================================================================
  RCS file: /home/cvs/xml-axkit/lib/Apache/AxKit/Attic/Pipeline.pm,v
  retrieving revision 1.1.2.6
  retrieving revision 1.1.2.7
  diff -u -r1.1.2.6 -r1.1.2.7
  --- Pipeline.pm       31 Oct 2003 00:06:22 -0000      1.1.2.6
  +++ Pipeline.pm       10 Dec 2003 22:50:45 -0000      1.1.2.7
  @@ -5,6 +5,7 @@
   use Apache::Constants;
   use Apache::Request;
   use Apache::AxKit::Provider;
  +use Apache::AxKit::Provider::Scalar;
   
   sub new{
        my ($class) = shift;
  @@ -12,18 +13,37 @@
        my $self = {
                upstream                => $args{'upstream'},
                href                    => $args{'href'},
  +             stage                   => $args{'stage'},
        };
        bless $self, $class;
        return $self;
   }
   
  -sub init{
  +sub pipeline_init{
  +     # $self, $r
  +     shift->upstream()->pipeline_init( @_ );
  +}    
  +
  +sub stage{   
        my $self = shift;
  -     my $r = shift;
  +     if(@_) {
  +             $self->{'stage'} = shift;
  +             return $self;
  +     } else {
  +             if($self->{'stage'}) {
  +                     return $self->{'stage'} 
  +             } else {
  +                     return $self->upstream()->stage();
  +             }
  +     }
  +}
   
  -     $self->upstream()->init( $r );
  +sub href{            return shift->{'href'} }
   
  -     if ($self->stylesheet_exists()) {
  +sub style_provider{  
  +     my $self = shift; 
  +     my $r = shift;
  +     unless( $self->{'style_provider'} ) {
        
                my $styleprovider = 
Apache::AxKit::Provider->new_style_provider( $r, uri => $self->href());
                
  @@ -33,27 +53,10 @@
                        );
                }
                
  -             $self->style( $styleprovider );
  -     }
  -     
  -}
  -
  -# Useful for debugging.
  -sub set_stage{
  -     my $self = shift;
  -     my $stage = $self->upstream()->set_stage() + 1;
  -     $self->{'stage'} = $stage;
  -     return $stage;
  -}
  -     
  -
  -sub stage{           return shift->{'stage'} }
  -sub href{            return shift->{'href'} }
  +             $self->{'style_provider'}=  $styleprovider ;
   
  -sub style{   
  -     my $self = shift; 
  -     if(@_) { $self->{'style'} = shift; return $self;} 
  -     return $self->{'style'} 
  +     }
  +     return $self->{'style_provider'};
   }
   
   
  @@ -63,7 +66,7 @@
                if($self->{'upstream'}) {
                        # Allow pipelines to be treated as one object
                        
  -                     $self->{'upstream'}->upstream( shift )
  +                     $self->{'upstream'}->upstream( @_ )
                } else {
                        $self->{'upstream'} = shift; 
                }
  @@ -87,18 +90,20 @@
        # into it's key), so we can ignore all parameters.....
        # In the middle ideally we should only take into account parameters 
which are actually used.
        
  -     my $key = $self->upstream()->key( $r );
  -        $key .= $self->stage();
  -        $key .= $self->style()->key() if $self->stylesheet_exists();
  +     return join('', $self->upstream()->key( $r ), $self->stage(), 
$self->href());
  +
  +    # use href() over style()->key() as it amounts to the same thing,
  +    # but href() avoids a SLOW call to $r->lookup_uri()
  +    # $key .= $self->style()->key() if $self->stylesheet_exists();
   
  -     return $key;
  -     
   }
   
  -sub has_changed{ return shift->upstream()->has_changed( shift ) };
  +sub has_changed{ 
  +     return shift->upstream()->has_changed( @_ ) 
  +};
   
  -sub get_ext_ent_handler{
  -     return shift->upstream()->get_ext_ent_handler( @_ );
  +sub get_ext_ent_handler{ 
  +     return shift->upstream()->get_ext_ent_handler( @_ ); 
   }
   
   sub cache_required{
  @@ -106,28 +111,37 @@
   }
   
   sub get_dom {
  -    my $self = shift;
  -    # sub classes should overload this
  -    # or get_strref at a minimum.
  +     my $self = shift;
        my $r = shift;
  +
        my $parser = XML::LibXML->new();
        $parser->expand_entities(1);
       Apache::AxKit::LibXMLSupport->reset;
  -    return $parser->parse_string(${$self->get_strref($r, 0)}, $r->uri());
  +    return $parser->parse_string(${ $self->get_strref( $r )}, $r->uri());
   }
   
   sub get_strref{
  -     my $self = shift;
  -     my $r = shift;
  -     my $str = $self->get_dom( $r )->toString();
  +     # $self, $r
  +     my $str = shift->get_dom( @_ )->toString();
        return \$str;
   }
   
   sub get_bytes_ref{
  +     my ($self, $r ) = @_;
  +     my $str_ref = $self->get_strref( $r );  
  +     if($AxKit::Pipeline->post_styles_pending()){
  +             my $provider = Apache::AxKit::Provider::Scalar->new( $r, 
${$str_ref} );
  +             $str_ref =  $AxKit::Pipeline->create_post_pipeline( $r, 
$provider )->get_bytes_ref( $r );
  +     }
  +     return $str_ref;
  +}
  +
  +sub get_provider{
        my $self = shift;
        my $r = shift;
  -     my $str = $self->get_strref( $r );
  -     return $str
  +     my $str_ref = $self->get_strref( $r );
  +     my $provider = Apache::Axkit::Provider::Scalar->new($r, ${$str_ref} );
  +     return $provider;
   }
   
   sub send_sax{
  @@ -157,16 +171,14 @@
       # Let's call this feature deprecated. (sp?), ie, it ain't going
       # to be here for long. 
       
  -    bless $r, 'AxKit::Apache';
  -    tie *STDOUT, 'AxKit::Apache', $r;   
  -    
  -     my $bytes = $self->get_bytes_ref( $r );
  -     
  -    my $result_code = $r->status();
  +    my $bytes;
  +    my $result_code; 
   
  +     $bytes = $self->get_bytes_ref( $r );
  +     $result_code = $r->status();
  + 
       if (ref($r) eq 'AxKit::Apache') {
           bless $r, 'Apache';
  -        tie *STDOUT, 'Apache', $r;
       }
       
       if( $AxKit::Cfg->DoGzip() ) {
  @@ -181,8 +193,6 @@
        $r->print($$bytes);
        return OK;
   }    
  -
  -sub stylesheet_exists { 1; } 
   
   sub enable_dynamic_styles{ 0 };
   
  
  
  
  No                   revision
  No                   revision
  1.1.2.3   +56 -63    xml-axkit/lib/Apache/AxKit/Pipeline/Attic/Cache.pm
  
  Index: Cache.pm
  ===================================================================
  RCS file: /home/cvs/xml-axkit/lib/Apache/AxKit/Pipeline/Attic/Cache.pm,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- Cache.pm  29 Oct 2003 21:42:53 -0000      1.1.2.2
  +++ Cache.pm  10 Dec 2003 22:50:45 -0000      1.1.2.3
  @@ -40,7 +40,7 @@
        local *AxKit::add_depends = sub { $self->add_depends(@_); 
&$axkit_add_depends(@_) };
   
        # removed media/style from the cache key
  -     # since $self->key() is not the pipeline key
  +     # since $self->key() is now the pipeline key
        # which is the result of the media/style choice.
   
        # No .gzip bit here, since we'll always be wanting a dom....we are not 
last in chain.
  @@ -169,78 +169,75 @@
   sub send{
       my ($self, $r) = @_;
   
  +     my $bytes;
        # See A::A::Pipeline.pm for what this is about.
  +     do {
  +#            local(*STDOUT);
   
  -    bless $r, 'AxKit::Apache';
  -    tie *STDOUT, 'AxKit::Apache', $r;   
  -
  -     # chain in a add_depends handler
  -     # which will call the underlying one.
  -     # This way we see everything loaded in the pipeline above us, without
  -     # changing any interfaces
  +             # chain in a add_depends handler
  +             # which will call the underlying one.
  +             # This way we see everything loaded in the pipeline above us, 
without
  +             # changing any interfaces
   
  -     my $axkit_add_depends = \&AxKit::add_depends;
  -     local *AxKit::add_depends = sub { 
  -             $self->add_depends(@_); &$axkit_add_depends(@_) };
  +             my $axkit_add_depends = \&AxKit::add_depends;
  +             local *AxKit::add_depends = sub { 
  +                     $self->add_depends(@_); &$axkit_add_depends(@_) };
   
  -     # removed media/style from the cache key
  -     # since $self->key() is not the pipeline key
  -     # which is the result of the media/style choice.
  +             # removed media/style from the cache key
  +             # since $self->key() is not the pipeline key
  +             # which is the result of the media/style choice.
   
  -     my $debug = $r->dir_config('AxCacheDebugHeaders');
  +             my $debug = $r->dir_config('AxCacheDebugHeaders');
   
  -    my $cache = Apache::AxKit::Cache->new(
  -     $r, $self->key( $r ) . ($AxKit::Cfg->GzipOutput ? '.gzip' : '') . 
($r->path_info() || ''), 
  -    );
  +     my $cache = Apache::AxKit::Cache->new(
  +             $r, $self->key( $r ) . ($AxKit::Cfg->GzipOutput ? '.gzip' : '') 
. ($r->path_info() || ''), 
  +     );
   
  -     $self->{'_cache'} = $cache;
  +             $self->{'_cache'} = $cache;
        
  -     my $bytes;
  -     my $str;
  -     my $stage = $self->stage();
  +             my $str;
  +             my $stage = $self->stage();
   
        # if provider is newer or dependancies not upto date
        # then call upstream, cache response, and save dependancies.
  -     if( $cache->no_cache() || $r->no_cache() || $r->method() eq 'POST' || 
$r->status() != 200) {
  -             AxKit::Debug(4, "Cache[$stage]: Cache disabled, requesting 
upstream XML");
  -             $r->no_cache(1);
  -             $bytes = $self->upstream()->get_bytes_ref( $r );
  -             $r->header_out('X-AxKit-Cache', 'disabled') if $debug;
  -
  -     } elsif( !$self->upstream()->has_changed( $cache->mtime() )  && 
  -                             # Cache->read() does dependency checks.
  -                             $cache->exists() && ( $str = $cache->read( ) ) 
) {
  -             AxKit::Debug(4, "Cache[$stage] Successful cache read, 
attempting fast-deliver...");
  -             $r->header_out('X-AxKit-Cache', 'hit') if $debug;
  -             $cache->deliver( $r );
  -             return DECLINED;
  -     } else {
  -             AxKit::Debug(4, "Cache[$stage]: Cache miss, requesting upstream 
XML.");
  -             $self->cached(0);               
  -             $bytes = $self->upstream()->get_bytes_ref( $r );
  +             if( $cache->no_cache() || $r->no_cache() || $r->method() eq 
'POST' || $r->status() != 200) {
  +                     AxKit::Debug(4, "Cache[$stage]: Cache disabled, 
requesting upstream XML");
  +                     $r->no_cache(1);
  +                     $bytes = $self->upstream()->get_bytes_ref( $r );
  +                     $r->header_out('X-AxKit-Cache', 'disabled') if $debug;
  +
  +             } elsif( !$self->upstream()->has_changed( $cache->mtime() )  && 
  +                                     $cache->exists() && ( 
$cache->check_dependencies( ) ) ) {
  +                     AxKit::Debug(4, "Cache[$stage] Successful cache read, 
attempting fast-deliver...");
  +                     $r->header_out('X-AxKit-Cache', 'hit') if $debug;
  +                     $cache->deliver( $r );
  +                     return DECLINED;
  +             } else {
  +                     AxKit::Debug(4, "Cache[$stage]: Cache miss, requesting 
upstream XML.");
  +                     $self->cached(0);               
  +                     $bytes = $self->upstream()->get_bytes_ref( $r );
                
  -             if($r->status() == 200 && ! $r->no_cache() ) {
  +                     if($r->status() == 200 && ! $r->no_cache() ) {
   
  -                     AxKit::Debug(4, "Cache[$stage]: Cache doing write and 
pass-through.");
  -                     $cache->set_type( $r->content_type() );
  -                     $cache->add_dependencies( $self->get_depends() );
  -                     $r->header_out('X-AxKit-Cache', 'miss+write') if $debug;
  -                     if($cache->write( $bytes )) {
  -                             AxKit::Debug(4, "Cache[$stage]: Cache doing 
write and fast-deliver.");
  -                             # We're last in chain, and there are no output 
transformers. 
  -                             # do a fast delivery.
  -                             $cache->deliver( $r );
  -                             return DECLINED;
  +                             AxKit::Debug(4, "Cache[$stage]: Cache doing 
write and pass-through.");
  +                             $cache->set_type( $r->content_type() );
  +                             $cache->add_dependencies( $self->get_depends() 
);
  +                             $r->header_out('X-AxKit-Cache', 'miss+write') 
if $debug;
  +                             if($cache->write( $bytes )) {
  +                                     AxKit::Debug(4, "Cache[$stage]: Cache 
doing write and fast-deliver.");
  +                                     # We're last in chain, and there are no 
output transformers. 
  +                                     # do a fast delivery.
  +                                     $cache->deliver( $r );
  +                                     return DECLINED;
  +                             }
  +                     } else {
  +                             $r->header_out('X-AxKit-Cache', 
'miss+disabled') if $debug;
  +                             AxKit::Debug(4, "Cache[$stage]: Cache disabled 
due to status code or no_cache.");
                        }
  -             } else {
  -                     $r->header_out('X-AxKit-Cache', 'miss+disabled') if 
$debug;
  -                     AxKit::Debug(4, "Cache[$stage]: Cache disabled due to 
status code or no_cache.");
                }
  -     }
  -
  +     };
       if (ref($r) eq 'AxKit::Apache') {
           bless $r, 'Apache';
  -        tie *STDOUT, 'Apache', $r;
       }
   
       if( $AxKit::Cfg->DoGzip() ) {
  @@ -258,9 +255,6 @@
        # do the deliver thing. 
   }
   
  -
  -sub stylesheet_exists{ 0; }
  -
   sub cached{
        my $self = shift;
        $self->{'cached'} = $_[0] if @_;
  @@ -281,20 +275,19 @@
        return keys %{shift()->{'depends'}};
   }
   
  -sub init{
  +sub pipeline_init{
        my $self = shift;
        my $r = shift;
        my $axkit_add_depends = \&AxKit::add_depends;
        local *AxKit::add_depends = sub { 
                $self->add_depends(@_); &$axkit_add_depends(@_) 
        };
  -     return $self->upstream()->init($r);
  +     return $self->upstream()->pipeline_init($r);
   }
   
   sub key{
        my ($self, $r) = @_;
  -     return $self->stage() != 1 ? $self->SUPER::key( $r 
).$r->notes('axkit_cache_extra') :
  -                                                              
$self->SUPER::key( $r );
  +     return $self->SUPER::key( $r ).$r->notes('axkit_cache_extra');
   }
   
   
  
  
  
  1.1.2.4   +40 -22    xml-axkit/lib/Apache/AxKit/Pipeline/Attic/Head.pm
  
  Index: Head.pm
  ===================================================================
  RCS file: /home/cvs/xml-axkit/lib/Apache/AxKit/Pipeline/Attic/Head.pm,v
  retrieving revision 1.1.2.3
  retrieving revision 1.1.2.4
  diff -u -r1.1.2.3 -r1.1.2.4
  --- Head.pm   27 Oct 2003 00:59:55 -0000      1.1.2.3
  +++ Head.pm   10 Dec 2003 22:50:45 -0000      1.1.2.4
  @@ -10,8 +10,8 @@
   
   $VERSION = 1.0; # this fixes a CPAN.pm bug. Bah!
   
  -sub init{
  -     return 
  +sub pipeline_init{
  +     return ;
   };
   
   sub new{
  @@ -25,7 +25,14 @@
   }
   
   sub get_strref{
  -     return shift->upstream()->get_strref();
  +     my $self = shift;
  +     my $r = shift;
  +     my $str;
  +     if( $str = $r->pnotes('xml_string') ) {
  +             return \$str;
  +     } else {
  +             return $self->upstream()->get_strref();
  +     }
   }
   
   sub cache_required{
  @@ -33,27 +40,21 @@
   }
   
   sub key{
  -     return shift->upstream()->key( shift );
  +     return shift->upstream()->key( @_ );
   }   
       
   sub send_sax{
        my ($self, $r, $parser, $pipeline ) = @_;
        
        $parser->set_handler( Handler => $pipeline );
  -     
  -     my $provider = $self->upstream();
  -     
  +
        my $result;
        
  -     eval {
  -             my $fh = $provider->get_fh();
  -             $result = $parser->parse_fh($fh, $r->uri());
  -     };
  -     if ($@) {
  -             my $xmlstring = ${$provider->get_strref()};
  -             undef $@;
  +     my $provider = $self->upstream();
  +     if( my $str = $r->pnotes('xml_string') ) {
  +             use bytes;
                eval {
  -                     $result = $parser->parse_string( $xmlstring );
  +                     $result = $parser->parse_string( $str );
                };
                if($@) {
                        my $error = $@;
  @@ -61,15 +62,32 @@
                        -text => "SAX Error: $error"
                        );
                }
  +     } else {                                
  +             eval {
  +                     my $fh = $provider->get_fh();
  +                     $result = $parser->parse_fh($fh, $r->uri());
  +             };
  +             if ($@) {
  +                     use bytes;
  +                     my $xmlstring = ${$provider->get_strref()};
  +                     undef $@;
  +                     eval {
  +                             $result = $parser->parse_string( $xmlstring );
  +                     };
  +                     if($@) {
  +                             my $error = $@;
  +                             throw Apache::AxKit::Exception::Error(
  +                                     -text => "SAX Error: $error"
  +                             );
  +                     }
  +             }
        }
  -     
  +             
        return $result;
   }    
  -    
  -sub stylesheet_exists{ 0; }
  -
  -sub set_stage{
  -     return 0;
  -}
  +  
  +sub stage{
  +     return 'provider';
  +}  
   
   1;
  
  
  
  1.1.2.3   +102 -52   xml-axkit/lib/Apache/AxKit/Pipeline/Attic/Language.pm
  
  Index: Language.pm
  ===================================================================
  RCS file: /home/cvs/xml-axkit/lib/Apache/AxKit/Pipeline/Attic/Language.pm,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- Language.pm       27 Oct 2003 00:59:55 -0000      1.1.2.2
  +++ Language.pm       10 Dec 2003 22:50:45 -0000      1.1.2.3
  @@ -3,6 +3,8 @@
   use strict;
   use vars qw/@ISA $VERSION %DEPENDS/;
   use Apache;
  +use AxKit;
  +use Data::Dumper;
   use Apache::Constants qw/:common/;
   use Apache::Request;
   use Apache::AxKit::Pipeline;
  @@ -29,15 +31,15 @@
        return shift->upstream()->has_changed( shift );
   }
        
  -sub stylesheet_exists{
  -     return shift->{'module'}->stylesheet_exists();
  -}
   
   sub get_dom {
       my $self = shift;
       my ( $r ) = @_;
        my $stage = $self->stage();
   
  +     delete $r->pnotes()->{'dom_tree'};
  +     delete $r->pnotes()->{'xml_string'};
  +     my $xml_doc;
        $r->pnotes->{'dom_tree'} = $self->upstream()->get_dom( $r );
   
        my $module = $self->{'module'};
  @@ -45,79 +47,127 @@
        AxKit::Debug(3, "Pipeline[$stage]: About to execute: 
$module\::handler");
        AxKit::load_module($module);    
   
  -     my $rc= $module->handler(
  -             $r, $self->SUPER::upstream(), $self->{'style'}, 0
  -     );
  -
  -     if( ! ($rc == 200 || $rc == OK) ) {
  -             $r->status($rc);
  -     }
  -
  -     my $xml_doc;
  -
  -    if (my $dom = $r->pnotes('dom_tree')) {
  -        $xml_doc = $dom;
  -    }
  -    else {
  -     # Load here since we should have dom support available
  -     # but doesn't stop us if we don't and are using strref
  -             require 'XML/LibXML.pm';
  -             require 'Apache/AxKit/LibXMLSupport.pm';
  +     do {
  +             local( *STDOUT );
  +             my $buffer = tie *STDOUT, 'AxKit::Buffer';
  +     
  +             my $style = $module->stylesheet_exists() ? 
$self->style_provider( $r ) : undef;
  +     
  +             my $rc= $module->handler(
  +                     $r, $self->SUPER::upstream(), $style, 0
  +             );
  +
  +             if( ! ($rc == 200 || $rc == OK) ) {
  +                     $r->status($rc);
  +             }
  +
  +     if (my $dom = $r->pnotes('dom_tree')) {
  +         $xml_doc = $dom;
  +     }
  +     else {
  +             # Load here since we should have dom support available
  +             # but doesn't stop us if we don't and are using strref
  +                     require 'XML/LibXML.pm';
  +                     require 'Apache/AxKit/LibXMLSupport.pm';
        
  -        my $xmlstring = $r->pnotes('xml_string');  
  -             my $parser = XML::LibXML->new();
  -            $parser->expand_entities(1);
  +         my $xmlstring = $buffer->content();  
  +                     my $parser = XML::LibXML->new();
  +                    $parser->expand_entities(1);
               
  -             Apache::AxKit::LibXMLSupport->reset;            
  -             
  -         $xml_doc = $parser->parse_string($xmlstring, $r->uri());
  -     }
  -     delete $r->pnotes()->{'dom_tree'};
  -     delete $r->pnotes()->{'xml_string'};
  -
  +                     Apache::AxKit::LibXMLSupport->reset;            
  +                     
  +                 $xml_doc = $parser->parse_string($xmlstring, $r->uri());
  +             }
  +             delete $r->pnotes()->{'dom_tree'};
  +             delete $r->pnotes()->{'xml_string'};
  +     };
        return $xml_doc;
   }
       
   sub get_strref{
       my $self = shift;
       my ( $r ) = @_;
  -
  +    
        my $stage = $self->stage();
  -     
  +     my $str;
        # call strref, cause we have to assume we don't have libxml available.
        # so no dom.
   
  -     $r->pnotes->{'xml_string'} = ${$self->upstream()->get_strref( $r )};
  +     $r->pnotes('xml_string', ${$self->upstream()->get_strref( $r )});
   
        my $module = $self->{'module'};
  -     
  -     AxKit::Debug(3, "Pipeline[$stage]: About to load: $module  ");
  +
  +     AxKit::Debug(3, "Pipeline[$stage]: About to execute: 
$module\::handler");
        AxKit::load_module($module);    
   
  -     $r->notes('resetstring',1);
  -     
  -     #last in chain flag here!
  +     do {
   
  -     my $rc = $module->handler(
  -             $r, $self->SUPER::upstream(), $self->{'style'}, 0
  -     );
  +             local( *STDOUT );
  +             my $buffer = tie *STDOUT, 'AxKit::Buffer';
   
  -     if( ! ($rc == 200 || $rc == OK) ) {
  -             $r->status($rc);
  -     }
  +             my $style = $module->stylesheet_exists() ? 
$self->style_provider( $r ) : undef;
   
  -     my $str;
  -     
  -    unless ($str = $r->pnotes('xml_string')) {
  -        $str = $r->pnotes('dom_tree')->toString();
  -    }
  +             my $rc = $module->handler(
  +                     $r, $self->SUPER::upstream(), $style, 0
  +             );
   
  -     delete $r->pnotes()->{'dom_tree'};
  -     delete $r->pnotes()->{'xml_string'};
  +             if( ! ($rc == 200 || $rc == OK) ) {
  +                     $r->status($rc);
  +             }
  +     
  +             unless ($str = $buffer->content()) {
  +             $str = $r->pnotes('dom_tree')->toString();
  +         }
   
  +             delete $r->pnotes()->{'dom_tree'};
  +             delete $r->pnotes()->{'xml_string'};
  +     };
  +     
        return \$str;
   }
   
  +sub get_bytes_ref{
  +     # Needed for last in chain support, sigh.
  +    my $self = shift;
  +    my ( $r ) = @_;
  +    
  +     my $stage = $self->stage();
  +     my $str;
  +     # call strref, cause we have to assume we don't have libxml available.
  +     # so no dom.
  +
  +     $r->pnotes('xml_string', ${$self->upstream()->get_strref( $r )});
  +
  +     my $module = $self->{'module'};
  +
  +     AxKit::Debug(3, "Pipeline[$stage]: About to execute: 
$module\::handler");
  +     AxKit::load_module($module);    
  +
  +     do {
  +
  +             local( *STDOUT );
  +             my $buffer = tie *STDOUT, 'AxKit::Buffer';
  +
  +             my $style = $module->stylesheet_exists() ? 
$self->style_provider( $r ) : undef;
  +
  +             my $rc = $module->handler(
  +                     $r, $self->SUPER::upstream(), $style, 1 # last in chain.
  +             );
  +
  +             if( ! ($rc == 200 || $rc == OK) ) {
  +                     $r->status($rc);
  +             }
  +     
  +             unless ($str = $buffer->content()) {
  +             $str = $r->pnotes('dom_tree')->toString();
  +         }
  +
  +             delete $r->pnotes()->{'dom_tree'};
  +             delete $r->pnotes()->{'xml_string'};
  +     };
  +     
  +     return \$str;
  +}
   
   
   
  
  
  
  1.1.2.2   +20 -8     xml-axkit/lib/Apache/AxKit/Pipeline/Attic/LibXSLT.pm
  
  Index: LibXSLT.pm
  ===================================================================
  RCS file: /home/cvs/xml-axkit/lib/Apache/AxKit/Pipeline/Attic/LibXSLT.pm,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- LibXSLT.pm        20 Oct 2003 20:58:01 -0000      1.1.2.1
  +++ LibXSLT.pm        10 Dec 2003 22:50:45 -0000      1.1.2.2
  @@ -76,7 +76,8 @@
        
        return $self->{_stylesheet} if $self->{_stylesheet};
        
  -     my $style = $self->style();
  +     my $style = $self->style_provider( $r );
  +     
       my $stylesheet;
       my $cache = $style_cache{$style->key()};
       if (ref($cache) eq 'HASH' && !$style->has_changed($cache->{mtime}) && 
ref($cache->{depends}) eq 'ARRAY') {
  @@ -131,22 +132,33 @@
        return \$str;
   }
        
  +     
   sub get_bytes_ref{
        # This takes into account any xsl:output methods.
        # Since the output might not be xml...
        my ($self, $r ) = @_;
        my $results = $self->get_dom( $r );
  +     
        my $str;
        
  -     my $stylesheet = $self->get_stylesheet($r);
  -     if ($XML::LibXSLT::VERSION >= 1.03) {
  -             my $encoding = $stylesheet->output_encoding;
  -             my $type = $stylesheet->media_type;
  -             $r->content_type("$type; charset=$encoding");
  +     if( $AxKit::Pipeline->post_styles_pending()) {
  +             # We're no longer last in chain....
  +             my $provider = Apache::AxKit::Provider::DOM->new( $r, $results 
);
  +             $str = $AxKit::Pipeline->create_post_pipeline( $r, $provider 
)->get_bytes_ref( $r );    
  +     
  +     } else {
  +     
  +             my $stylesheet = $self->get_stylesheet($r);
  +             if ($XML::LibXSLT::VERSION >= 1.03) {
  +                     my $encoding = $stylesheet->output_encoding;
  +                     my $type = $stylesheet->media_type;
  +                     
  +                     $r->content_type("$type; charset=$encoding");   
  +             }
  +
  +             $str = $stylesheet->output_string($results);
        }
  -     $str = $stylesheet->output_string($results);
        return \$str;
  -
   }
   
   
  
  
  
  1.1.2.2   +7 -6      xml-axkit/lib/Apache/AxKit/Pipeline/Attic/SAX.pm
  
  Index: SAX.pm
  ===================================================================
  RCS file: /home/cvs/xml-axkit/lib/Apache/AxKit/Pipeline/Attic/SAX.pm,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- SAX.pm    22 Oct 2003 21:48:29 -0000      1.1.2.1
  +++ SAX.pm    10 Dec 2003 22:50:45 -0000      1.1.2.2
  @@ -28,13 +28,11 @@
        return shift->{'saxprocessor'};
   };
   
  -sub init{
  +sub pipeline_init{
        my ($self, $r) = @_;
        
  -     $self->upstream()->init( $r );
  -     my $processor = $self->saxprocessor();
  -     AxKit::Debug(3, "SAX: about to load $processor");
  -    AxKit::load_module($processor);
  +     $self->upstream()->pipeline_init( $r );
  +
        return $self;
   }
   
  @@ -61,11 +59,14 @@
   
   sub send_sax{
        my ($self, $r, $parser, $pipeline) = @_;
  +
  +     my $instance = $self->saxprocessor();
        
  -     my $instance = $self->saxprocessor();   
        if(ref($instance)) {
                $instance->set_handler(Handler => $pipeline);
        } else {
  +             AxKit::Debug(3, "SAX: about to load $instance");
  +     AxKit::load_module($instance);
                $instance = $instance->new( Handler => $pipeline );
        }
        my $stage = $self->stage();
  
  
  
  1.1.2.2   +1 -9      xml-axkit/lib/Apache/AxKit/Pipeline/Attic/Trace.pm
  
  Index: Trace.pm
  ===================================================================
  RCS file: /home/cvs/xml-axkit/lib/Apache/AxKit/Pipeline/Attic/Trace.pm,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- Trace.pm  20 Oct 2003 20:58:01 -0000      1.1.2.1
  +++ Trace.pm  10 Dec 2003 22:50:45 -0000      1.1.2.2
  @@ -28,6 +28,7 @@
       my $xmldoc = $self->upstream()->get_dom( $r );
        local $XML::LibXML::setTagCompression = 1;
        my $xmlstr = $xmldoc->toString(1) || "<?xml version='1.0'?>\n<empty 
reason='no data found'/>\n";
  +     
        $self->write_trace( $r, $xmlstr);       
        return $xmldoc;
   }
  @@ -76,14 +77,6 @@
                close($fh);
        }
   }
  -     
  -sub set_stage{
  -     my $self = shift;
  -     # Don't increment stage count.
  -     my $stage = $self->upstream()->set_stage();
  -     $self->{'stage'} = $stage;
  -     return $stage;
  -}    
   
   
   sub interm_prefix{
  @@ -118,6 +111,5 @@
        return $self->{'interm_prefix'};
   }
       
  -sub stylesheet_exists{ 0; }
   
   1;
  
  
  
  1.1.2.3   +0 -1      xml-axkit/lib/Apache/AxKit/Pipeline/Attic/Transformer.pm
  
  Index: Transformer.pm
  ===================================================================
  RCS file: /home/cvs/xml-axkit/lib/Apache/AxKit/Pipeline/Attic/Transformer.pm,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- Transformer.pm    29 Oct 2003 21:42:53 -0000      1.1.2.2
  +++ Transformer.pm    10 Dec 2003 22:50:45 -0000      1.1.2.3
  @@ -43,7 +43,6 @@
        return \$str;           
   }
       
  -sub stylesheet_exists{ 0; }
   
   sub output_binary{ 1 };
   
  
  
  
  1.1.2.3   +3 -4      xml-axkit/lib/Apache/AxKit/Pipeline/Attic/XSP.pm
  
  Index: XSP.pm
  ===================================================================
  RCS file: /home/cvs/xml-axkit/lib/Apache/AxKit/Pipeline/Attic/XSP.pm,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- XSP.pm    27 Oct 2003 00:59:55 -0000      1.1.2.2
  +++ XSP.pm    10 Dec 2003 22:50:45 -0000      1.1.2.3
  @@ -31,7 +31,7 @@
   # XML via an external downstream pipeline cache.
   
   
  -sub init{
  +sub pipeline_init{
   # Inorder to ensure that the version of the compiled XSP code an upstream 
cache
   # talks to, we have to ensure the XSP is consistent a soon as the upstream
   # pipeline is available, before any cache calls are made.
  @@ -45,7 +45,7 @@
                $self->add_depends(@_); &$axkit_add_depends(@_) 
        };
        
  -     $self->upstream()->init( $r );
  +     $self->upstream()->pipeline_init( $r );
        
       my $key = $self->SUPER::key( $r );       # Pipeline key.
   
  @@ -252,10 +252,9 @@
       return $dom;
   }
   
  -sub stylesheet_exists{  0; }
   
   sub enable_dynamic_styles{ 1 };
   
   1;
   
  -     
  \ No newline at end of file
  +     
  
  
  

Reply via email to