Hi!
I tried to implement get_dom in a content provder, but AxKit
insists on using get_strref !?!
In the POD documentation and Kip's AxKit book I read that
only one of get_dom, get_strref or get_fh is needed, and
get_dom would be the most efficient one - so I thought it
would also be the preferred one ;-) .
I added a get_strref again that outputs the dom tree with
toString, and its used by AxKit, but it seems inefficient
for me to convert it to a string and parse it again in
the next stage ...
I attached some lines from error_log and my test provider...
Maybe somebody could point at my error...
Peter Mueller
WOTLmade
#!/usr/bin/perl
use strict;
package elimpex::Apache::AxKit::TestProvider;
use Apache::AxKit::Provider;
use vars qw (@ISA);
@ISA = qw (Apache::AxKit::Provider);
use AxKit;
use Apache::AxKit::Exception;
use Apache::Log ();
use XML::LibXML;
use elimpex::nina::config;
sub init {
... code deleted ...
}
sub process {
my $self = shift;
... code deleted ...
$self->{'exists'} = 1; # note that this resource exists for later checks
#
# we do processing of the uri here and build up the dom tree
#
my $parser = XML::LibXML->new ();
my $doc = XML::LibXML->createDocument ();
... code deleted ...
$self->{'xml_dom'} = $doc;
return 1; # we process this URI
... code deleted ...
}
sub mtime {
... code deleted ...
return time (); # content is allways fresh.
}
sub key {
... code deleted ...
return $r->uri ();
}
sub exists {
... code deleted ...
return defined ($self->{'exists'});
}
sub get_dom {
... code deleted ...
return $self->{'xml_dom'};
}
sub get_strref {
... code deleted ...
unless (defined ($self->{'xml_text'})) {
unless (defined ($self->{'xml_dom'})) {
throw Apache::AxKit::Exception::Error (
-text => "cant get DOM representation of document"
);
}
my $xml_text = $self->{'xml_dom'}->toString ();
$self->{'xml_text'} = \$xml_text;
}
return $self->{'xml_text'};
}
1;
Notes:
.) My content provider logs each method call with <method>:start
.) AxDebugLevel is 10
[Wed May 25 15:26:51 2005] [warn] [client 10.42.0.14] [AxKit] fast handler
called for /test/index.xml
[Wed May 25 15:26:51 2005] [warn] [client 10.42.0.14] [AxKit] Content Provider
Override: elimpex::Apache::AxKit::TestProvider
[Wed May 25 15:26:51 2005] [debug]
/home/elimpex/perl/lib/elimpex/Apache/AxKit/TestProvider.pm(30): [client
10.42.0.14] init: start
[Wed May 25 15:26:51 2005] [debug]
/home/elimpex/perl/lib/elimpex/Apache/AxKit/TestProvider.pm(116): [client
10.42.0.14] key: start
[Wed May 25 15:26:51 2005] [warn] [client 10.42.0.14] [AxKit] checking if we
process this resource
[Wed May 25 15:26:51 2005] [debug]
/home/elimpex/perl/lib/elimpex/Apache/AxKit/TestProvider.pm(51): [client
10.42.0.14] process: start
[Wed May 25 15:26:51 2005] [debug]
/home/elimpex/perl/lib/elimpex/Apache/AxKit/TestProvider.pm(54): [client
10.42.0.14] process: uri (/test/index.xml)
[Wed May 25 15:26:51 2005] [debug]
/home/elimpex/perl/lib/elimpex/Apache/AxKit/TestProvider.pm(56): [client
10.42.0.14] process: path (/test/index.xml)
[Wed May 25 15:26:51 2005] [warn] [client 10.42.0.14] [AxKit] media: screen,
preferred style: #default
[Wed May 25 15:26:51 2005] [debug]
/home/elimpex/perl/lib/elimpex/Apache/AxKit/TestProvider.pm(116): [client
10.42.0.14] key: start
[Wed May 25 15:26:51 2005] [warn] [client 10.42.0.14] [AxKit] Cache: key =
489f258fa389b13fa6ebbf25da24e3b0
[Wed May 25 15:26:51 2005] [warn] [client 10.42.0.14] [AxKit] getting styles
and external entities from the XML
[Wed May 25 15:26:51 2005] [warn] [client 10.42.0.14] [AxKit] styles not cached
- calling $provider->get_styles()
[Wed May 25 15:26:51 2005] [debug]
/home/elimpex/perl/lib/elimpex/Apache/AxKit/TestProvider.pm(116): [client
10.42.0.14] key: start
[Wed May 25 15:26:51 2005] [debug]
/home/elimpex/perl/lib/elimpex/Apache/AxKit/TestProvider.pm(165): [client
10.42.0.14] get_strref: start
[Wed May 25 15:26:51 2005] [warn] [client 10.42.0.14] [AxKit] using XS
get_styles (libxml2)
[Wed May 25 15:26:51 2005] [warn] [client 10.42.0.14] [AxKit] calling
xs_get_styles_str()
[Wed May 25 15:26:51 2005] [warn] [client 10.42.0.14] [AxKit] xs_get_styles
returned: , , page
[Wed May 25 15:26:51 2005] [warn] [client 10.42.0.14] [AxKit] Calling
GetMatchingProcessors with (screen, , , , page)
[Wed May 25 15:26:51 2005] [warn] [client 10.42.0.14] [AxKit] get_styles:
loading style modules
[Wed May 25 15:26:51 2005] [warn] [client 10.42.0.14] [AxKit] get_styles:
looking for mapping for style type: 'text/xsl'
[Wed May 25 15:26:51 2005] [debug]
/home/elimpex/perl/lib/elimpex/Apache/AxKit/TestProvider.pm(102): [client
10.42.0.14] mtime: start
[Wed May 25 15:26:51 2005] [warn] [client 10.42.0.14] [AxKit] cache doesn't
exist
[Wed May 25 15:26:51 2005] [warn] [client 10.42.0.14] [AxKit] some condition
failed. recreating output
[Wed May 25 15:26:51 2005] [warn] [client 10.42.0.14] [AxKit] styles:
Apache::AxKit::Language::LibXSLT(/test/styles/test.xsl)
[Wed May 25 15:26:52 2005] [debug]
/home/elimpex/perl/lib/elimpex/Apache/AxKit/TestProvider.pm(165): [client
10.42.0.14] get_strref: start
[Wed May 25 15:26:52 2005] [warn] [client 10.42.0.14] [AxKit] Style Provider
Override: Apache::AxKit::Provider::File
[Wed May 25 15:26:52 2005] [warn] [client 10.42.0.14] [AxKit] encoding to UTF-8
[Wed May 25 15:26:52 2005] [warn] [client 10.42.0.14] [AxKit] [uri] File
Provider looking up uri (/test/styles/test.xsl)
[Wed May 25 15:26:52 2005] [warn] [client 10.42.0.14] [AxKit] decoding from
UTF-8
[Wed May 25 15:26:52 2005] [warn] [client 10.42.0.14] [AxKit] [uri] File
Provider set filename to /home/elimpex/www/test/styles/test.xsl
[Wed May 25 15:26:52 2005] [warn] [client 10.42.0.14] [AxKit] about to execute:
Apache::AxKit::Language::LibXSLT::handler
[Wed May 25 15:26:52 2005] [warn] [client 10.42.0.14] [AxKit] [LibXSLT] getting
the XML
[Wed May 25 15:26:52 2005] [warn] [client 10.42.0.14] [AxKit] [LibXSLT] parsing
stylesheet
[Wed May 25 15:26:52 2005] [warn] [client 10.42.0.14] [AxKit] [LibXSLT] parsing
stylesheet /test/styles/test.xsl
[Wed May 25 15:26:52 2005] [warn] [client 10.42.0.14] [AxKit] Provider::get_dom
[Wed May 25 15:26:52 2005] [warn] [client 10.42.0.14] [AxKit]
Provider::get_dom/parse_fh(GLOB(0x8b352a8), /test/styles/test.xsl)
[Wed May 25 15:26:52 2005] [warn] [client 10.42.0.14] [AxKit] [LibXSLT]
performing transformation
[Wed May 25 15:26:52 2005] [warn] [client 10.42.0.14] [AxKit] [LibXSLT]
transformation finished, creating XML::LibXML::Document=SCALAR(0x8b35338)
[Wed May 25 15:26:52 2005] [warn] [client 10.42.0.14] [AxKit] [LibXSLT]
outputting to $r
[Wed May 25 15:26:52 2005] [warn] [client 10.42.0.14] [AxKit] [LibXSLT] storing
results in pnotes(dom_tree) (AxKit::Apache=SCALAR(0x8af51c0))
[Wed May 25 15:26:52 2005] [warn] [client 10.42.0.14] [AxKit]
Apache::AxKit::Language::LibXSLT::handler finished with code 0
[Wed May 25 15:26:52 2005] [warn] [client 10.42.0.14] [AxKit] execution of:
Apache::AxKit::Language::LibXSLT::handler finished
[Wed May 25 15:26:52 2005] [warn] [client 10.42.0.14] [AxKit] delivering to
browser
[Wed May 25 15:26:52 2005] [warn] [client 10.42.0.14] [AxKit] Delivering
xml_string
[Wed May 25 15:26:52 2005] [warn] [client 10.42.0.14] [AxKit] writing xml
string to browser
Perlrequire /home/elimpex/config/startup.perl
LogLevel debug
PerlInitHandler Apache::RequestNotes
PerlSetVar MaxPostSize 10240
PerlSetVar Apache::RequestNotes::DEBUG 1
PerlModule AxKit
AxAddStyleMap application/x-xsp Apache::AxKit::Language::XSP
AxAddStyleMap text/xsl Apache::AxKit::Language::LibXSLT
Alias /test/ /home/elimpex/www/test/
<Directory /home/elimpex/www/test>
PerlInitHandler elimpex::Apache::Session
AuthType NINA_SESSION
AuthName NINA
Require valid-user
PerlSetVar NINA_LoginPage "/test/login.xml"
AddHandler AxKit .xml .xsp
DirectoryIndex /redirect?url=/xsp/index.xsp
AxContentProvider elimpex::Apache::AxKit::TestProvider
AxAddProcessor text/xsl /test/styles/test.xsl
AxCacheDir /home/elimpex/tmp
AxNoCache On
AxDebugLevel 10
AxTraceIntermediate /home/elimpex/tmp
AxDebugTidy On
AxStackTrace On
AxLogDeclines On
AxGzipOutput Off
</Directory>
<Directory /home/elimpex/www/test/styles>
Satisfy any
</Directory>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]