Subject: | XML::LibXML error "Couldn't create file parser context for file..." using A::X::U |
OS: Debian GNU/Linux Testing (Sarge):
Linux storage 2.4.24-1-686 #1 Wed Feb 18 21:59:13 EST 2004 i686 GNU/Linux
Distribution name and version:
bronto@storage:~$ perl -MAxKit::XSP::Util -e 'print "$AxKit::XSP::Util::VERSION\n"'
1.6
Perl version:
bronto@storage:~$ perl -v
This is perl, v5.8.3 built for i386-linux-thread-multi
Problem: Loading an XSP page built using AxKit::XSP::Util (<util:include-file>) and transformed in HTML using XPathScript I get this error:
[Wed Mar 17 10:22:43 2004] [error] [client 10.39.253.107] [AxKit] [Backtrace] Couldn't create file parser context for file "/var/www/storage/htdocs/maps/gig/gig.html": Success at /usr/local/lib/perl/5.8.3/XML/LibXML.pm line 430.
Apache::AxKit::Exception::new('Apache::AxKit::Exception::Error','-text','Couldn\'t create file parser context for file "/var/www/stora...') called at /usr/lib/perl5/AxKit.pm line 1015
Discussed this with pepl on #axkit, and we found that we could make patching Util this way we can make it work:
*** Util.pm.dist Wed Mar 17 10:24:15 2004
--- Util.pm Wed Mar 17 10:51:31 2004
***************
*** 20,26 ****
# insert from a local file
sub include_file {
my ($document, $parent, $filename) = @_;
! my $doc = XML::LibXML->new()->parse_file($filename);
if ($doc) {
my $root = $doc->getDocumentElement();
$root = $document->importNode($root);
--- 20,36 ----
# insert from a local file
sub include_file {
my ($document, $parent, $filename) = @_;
! my $parser = XML::LibXML->new() ;
! local($XML::LibXML::match_cb, $XML::LibXML::open_cb,
! $XML::LibXML::read_cb, $XML::LibXML::close_cb);
! Apache::AxKit::LibXMLSupport->reset();
! local $Apache::AxKit::LibXMLSupport::provider_cb =
! sub {
! my $r = shift;
! my $provider = Apache::AxKit::Provider->new_content_provider($r);
! return $provider;
! };
! my $doc = $parser->parse_file($filename);
if ($doc) {
my $root = $doc->getDocumentElement();
$root = $document->importNode($root);
Good luck!
Ciao
--bronto