-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi,
The input callback implementation of XML::LibXML and XML::LibXSLT has
changed in the respective CVS versions. The attached patch against
current AxKit SVN will help to get AxKit work again with the CVS version
of both LibX* modules. The release 1.59 of XML::LibXML and XML::LibXSLT
should not be too far away in time.
- --michael
- --
063A F25E B064 A98F A479 1690 78CD D023 5E2A 6688
http://zis.uibk.ac.at/.m/uibk.ac.at_pgp_pubkey.asc
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (MingW32)
iD8DBQFErM5meM3QI14qZogRAmbZAJ9PxkV5qfWaWu37JBnrkECWTLWRIgCfQTaO
DxOoXObepsKdRWQiuRKvCRw=
=JuEd
-----END PGP SIGNATURE-----
Index: lib/Apache/AxKit/Language/HtmlDoc.pm
===================================================================
--- lib/Apache/AxKit/Language/HtmlDoc.pm (revision 419205)
+++ lib/Apache/AxKit/Language/HtmlDoc.pm (working copy)
@@ -25,7 +25,8 @@
use Apache::Constants qw(:common);
use Apache::Request;
use Apache::AxKit::Language;
-use Apache::AxKit::LibXMLSupport;
+use Apache::AxKit::LibXML;
+use Apache::AxKit::LibXMLCallbacks;
use Apache::AxKit::Provider;
use XML::LibXSLT;
use IPC::Run qw(run);
@@ -40,16 +41,15 @@
my $class = shift;
my ($r, $xml_provider, undef, $last_in_chain) = @_;
- 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();
+ my $parser = Apache::AxKit::LibXML->new();
+ $parser->expand_xinclude(1);
my $dom;
my $source_text;
if ($dom = $r->pnotes('dom_tree')) {
;
- } elsif ($source_text = $r->pnotes('xml_string')) {
+ }
+ elsif ($source_text = $r->pnotes('xml_string')) {
$dom = $parser->parse_string($source_text, $r->uri());
}
else {
@@ -60,7 +60,6 @@
}
$dom = $parser->parse_string($source_text, $r->uri());
}
- $dom->process_xinclude();
my $style_dom = $parser->parse_string(<< 'EOX','.');
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/1999/xhtml">
@@ -69,7 +68,9 @@
<xsl:template match="text()"><xsl:value-of select="."/></xsl:template>
</xsl:stylesheet>
EOX
- my $stylesheet = XML::LibXSLT->parse_stylesheet($style_dom);
+ my $xslt = XML::LibXSLT->new();
+ $xslt->input_callbacks( Apache::AxKit::LibXMLCallbacks->input_callbacks()
);
+ $stylesheet = $xslt->parse_stylesheet($style_dom);
my $results = $stylesheet->transform($dom);
my $result;
Index: lib/Apache/AxKit/Language/XSP.pm
===================================================================
--- lib/Apache/AxKit/Language/XSP.pm (revision 419205)
+++ lib/Apache/AxKit/Language/XSP.pm (working copy)
@@ -19,6 +19,7 @@
use strict;
use AxKit;
+use Apache::AxKit::LibXML;
use Apache::AxKit::Language;
use Apache::Request;
use Apache::AxKit::Exception;
@@ -1079,7 +1080,7 @@
package AxKit::XSP::SAXParser;
use XML::LibXML 1.30;
-use Apache::AxKit::LibXMLSupport;
+use Apache::AxKit::LibXML;
sub new {
my ($type, %self) = @_;
@@ -1092,11 +1093,9 @@
my $doc;
if (ref($thing) ne 'XML::LibXML::Document') {
- 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($parser);
+ my $parser = Apache::AxKit::LibXML->new();
$parser->expand_entities(1);
+ $parser->expand_xinclude(1);
eval {
$parser->line_numbers(1);
AxKit::Debug(6,"enabled line numbers");
@@ -1108,9 +1107,9 @@
else {
$doc = $parser->parse_string($thing);
}
- AxKit::Debug(10, 'XSP: Parser returned doc');
- $doc->process_xinclude;
- } else {
+ AxKit::Debug(9, 'XSP: Parser returned doc');
+ }
+ else {
$doc = $thing;
}
Index: lib/Apache/AxKit/Language/LibXSLT.pm
===================================================================
--- lib/Apache/AxKit/Language/LibXSLT.pm (revision 419205)
+++ lib/Apache/AxKit/Language/LibXSLT.pm (working copy)
@@ -25,7 +25,8 @@
use Apache::Request;
use Apache::AxKit::Language;
use Apache::AxKit::Provider;
-use Apache::AxKit::LibXMLSupport;
+use Apache::AxKit::LibXML;
+use Apache::AxKit::LibXMLCallbacks;
use File::Basename qw(dirname);
@ISA = 'Apache::AxKit::Language';
@@ -62,11 +63,9 @@
$xmlstring = $r->pnotes('xml_string');
}
- my $parser = XML::LibXML->new();
+ my $parser = Apache::AxKit::LibXML->new();
$parser->expand_entities(1);
- local($XML::LibXML::match_cb, $XML::LibXML::open_cb,
- $XML::LibXML::read_cb, $XML::LibXML::close_cb);
- Apache::AxKit::LibXMLSupport->reset();
+ $parser->expand_xinclude(1);
local $Apache::AxKit::LibXMLSupport::provider_cb =
sub {
my $r = shift;
@@ -82,8 +81,6 @@
$xml_doc = $parser->parse_string($xmlstring, $r->uri());
}
- $xml_doc->process_xinclude();
-
AxKit::Debug(7, "[LibXSLT] parsing stylesheet");
my $stylesheet;
@@ -111,9 +108,8 @@
AxKit::Debug(7, "[LibXSLT] parsing stylesheet $style_uri");
my $style_doc = $style->get_dom();
- local($XML::LibXML::match_cb, $XML::LibXML::open_cb,
- $XML::LibXML::read_cb, $XML::LibXML::close_cb);
- Apache::AxKit::LibXMLSupport->reset();
+ my $xslt = XML::LibXSLT->new();
+ $xslt->input_callbacks(
Apache::AxKit::LibXMLCallbacks->input_callbacks() );
local $Apache::AxKit::LibXMLSupport::provider_cb =
sub {
my $r = shift;
@@ -122,7 +118,7 @@
return $provider;
};
- $stylesheet = XML::LibXSLT->parse_stylesheet($style_doc);
+ $stylesheet = $xslt->parse_stylesheet($style_doc);
unless ($r->dir_config('AxDisableXSLTStylesheetCache')) {
$style_cache{$style->key()} =
Index: lib/Apache/AxKit/LibXMLSupport.pm
===================================================================
--- lib/Apache/AxKit/LibXMLSupport.pm (revision 419205)
+++ lib/Apache/AxKit/LibXMLSupport.pm (working copy)
@@ -1,81 +0,0 @@
-# Copyright 2001-2005 The Apache Software Foundation
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-# $Id$
-
-package Apache::AxKit::LibXMLSupport;
-use strict;
-use XML::LibXML 1.50;
-use Apache::AxKit::Provider;
-
-use vars qw($provider_cb);
-
-sub reset {
- my $class = shift;
- $XML::LibXML::match_cb = \&match_uri;
- $XML::LibXML::read_cb = \&read_uri;
- $XML::LibXML::close_cb = \&close_uri;
- $XML::LibXML::open_cb = \&open_uri;
-}
-
-sub match_uri {
- my $uri = shift;
- AxKit::Debug(8, "LibXSLT match_uri: $uri");
- return 0 if $uri =~ /^(https?|ftp|file):/; # don't handle URI's supported
by libxml
- return 1 if !($uri =~ /^([a-zA-Z0-9]+):/);
- return Apache::AxKit::Provider::has_protocol($1);
-}
-
-sub open_uri {
- my $uri = shift || './';
- return
Apache::AxKit::Provider::get_uri($uri,AxKit::Apache->request(),$provider_cb);
-}
-
-sub close_uri {
- # do nothing
-}
-
-sub read_uri {
- return substr($_[0], 0, $_[1], "");
-}
-
-1;
-__END__
-
-=head1 NAME
-
-Apache::AxKit::LibXMLSupport - XML::LibXML support routines
-
-=head1 SYNOPSIS
-
- require Apache::AxKit::LibXMLSupport;
- Apache::AxKit::LibXMLSupport->setup_libxml();
-
-=head1 DESCRIPTION
-
-This module sets up some things for using XML::LibXML in AxKit. Specifically
this
-is to do with callbacks. All callbacks look pretty much the same in AxKit, so
-this module makes them editable in one place.
-
-=head1 API
-
-There is just one method: C<< Apache::AxKit::LibXMLSupport->setup_libxml() >>.
-
-You can pass a parameter, in which case it is a callback to create a provider
-given a C<$r> (an Apache request object). This is so that you can create the
-provider in different ways and register the fact that it was created. If you
-don't provide a callback though a default one will be provided.
-
-=cut
Index: lib/Apache/AxKit/LibXML.pm
===================================================================
--- lib/Apache/AxKit/LibXML.pm (revision 0)
+++ lib/Apache/AxKit/LibXML.pm (revision 0)
@@ -0,0 +1,42 @@
+# $Id$
+
+package Apache::AxKit::LibXML;
+
+use strict;
+use XML::LibXML 1.58;
+use Apache::AxKit::LibXMLCallbacks;
+
+use vars qw( @ISA $VERSION );
+
[EMAIL PROTECTED] = ('XML::LibXML');
+$VERSION = 1.0;
+
+sub new {
+ my $proto = shift;
+ my $class = ref( $proto ) || $proto;
+ my $self = $class->SUPER::new( @_ );
+
+ $self->input_callbacks( Apache::AxKit::LibXMLCallbacks->input_callbacks()
);
+
+ return $self;
+}
+
+1;
+__END__
+
+=head1 NAME
+
+Apache::AxKit::LibXML - XML::LibXML wrapper
+
+=head1 SYNOPSIS
+
+ use Apache::AxKit::LibXML;
+ my $parser = Apache::AxKit::LibXML->new();
+ my $doc = $parser->parse_string( $xmlstring );
+
+=head1 DESCRIPTION
+
+This module transparently registers the input callbacks from
+Apache::AxKit::LibXMLCallbacks for every parsing action.
+
+=cut
Property changes on: lib/Apache/AxKit/LibXML.pm
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Index: lib/Apache/AxKit/LibXMLCallbacks.pm
===================================================================
--- lib/Apache/AxKit/LibXMLCallbacks.pm (revision 0)
+++ lib/Apache/AxKit/LibXMLCallbacks.pm (revision 0)
@@ -0,0 +1,66 @@
+# $Id$
+
+package Apache::AxKit::LibXMLCallbacks;
+use strict;
+use XML::LibXML 1.50;
+use Apache::AxKit::Provider;
+
+use vars qw($provider_cb);
+
+sub input_callbacks {
+ my $class = shift;
+ my $icb = XML::LibXML::InputCallback->new();
+ $icb->register_callbacks( [ \&match_uri, \&open_uri,
+ \&read_uri, \&close_uri ] );
+ return $icb;
+}
+
+sub match_uri {
+ my $uri = shift;
+ AxKit::Debug(8, "LibXSLT match_uri: $uri");
+ return 0 if $uri =~ /^(https?|ftp|file):/; # don't handle URI's supported
by libxml
+ return 1 if !($uri =~ /^([a-zA-Z0-9]+):/);
+ return Apache::AxKit::Provider::has_protocol($1);
+}
+
+sub open_uri {
+ my $uri = shift || './';
+ return
Apache::AxKit::Provider::get_uri($uri,AxKit::Apache->request(),$provider_cb);
+}
+
+sub close_uri {
+ # do nothing
+}
+
+sub read_uri {
+ return substr(${$_[0]}, 0, $_[1], "");
+}
+
+1;
+__END__
+
+=head1 NAME
+
+Apache::AxKit::LibXMLCallbacks - XML::LibXML callback routines
+
+=head1 SYNOPSIS
+
+ use Apache::AxKit::LibXMLCallbacks;
+ my $icb = Apache::AxKit::LibXMLCallbacks->input_callbacks();
+
+=head1 DESCRIPTION
+
+This module sets up some things for using XML::LibXML in AxKit. Specifically
this
+is to do with callbacks. All callbacks look pretty much the same in AxKit, so
+this module makes them editable in one place.
+
+=head1 API
+
+There is just one method: C<< Apache::AxKit::LibXMLCallbacks->setup_libxml()
>>.
+
+You can pass a parameter, in which case it is a callback to create a provider
+given a C<$r> (an Apache request object). This is so that you can create the
+provider in different ways and register the fact that it was created. If you
+don't provide a callback though a default one will be provided.
+
+=cut
Property changes on: lib/Apache/AxKit/LibXMLCallbacks.pm
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Index: lib/Apache/AxKit/Provider.pm
===================================================================
--- lib/Apache/AxKit/Provider.pm (revision 419205)
+++ lib/Apache/AxKit/Provider.pm (working copy)
@@ -19,6 +19,7 @@
use strict;
use Apache::AxKit::Exception;
+use Apache::AxKit::LibXML;
use Apache::Constants qw(OK DECLINED);
use AxKit;
@@ -82,7 +83,7 @@
my $str = get_provider(@_)->get_strref;
- return $$str;
+ return $str;
}
# end of protocol utilities
@@ -163,39 +164,36 @@
require Apache::AxKit::LibXMLSupport;
AxKit::Debug(8, "Provider::get_dom");
- my $parser = XML::LibXML->new();
+ my $parser = Apache::AxKit::LibXML->new();
$parser->expand_entities(1);
$parser->expand_xinclude(1);
- local($XML::LibXML::match_cb, $XML::LibXML::open_cb,
- $XML::LibXML::read_cb, $XML::LibXML::close_cb);
- Apache::AxKit::LibXMLSupport->reset($parser);
my $r = $self->apache_request();
my $xml_doc;
if ($str) {
- use bytes;
+ use bytes;
AxKit::Debug(8, "Provider::get_dom/parse_string($str, ",
$self->get_document_uri(), ")");
$xml_doc = $parser->parse_string($str, $self->get_document_uri()) ||
throw Apache::AxKit::Exception::Error(
-text => "XML::LibXML->parse_string returned nothing!"
);
- } else {
- eval {
- my $fh = $self->get_fh();
- AxKit::Debug(8, "Provider::get_dom/parse_fh($fh, ",
$self->get_document_uri(), ")");
- $xml_doc = $parser->parse_fh($fh,
$self->get_document_uri());
- };
- if ($@) {
- use bytes;
- my $xmlstring = ${$self->get_strref()};
- AxKit::Debug(8,
"Provider::get_dom/parse_strref($xmlstring, ", $self->get_document_uri(), ")");
- $xml_doc = $parser->parse_string($xmlstring,
$self->get_document_uri()) ||
- throw Apache::AxKit::Exception::Error(
- -text => "XML::LibXML->parse_string
returned nothing!"
- );
- }
- }
+ } else {
+ eval {
+ my $fh = $self->get_fh();
+ AxKit::Debug(8, "Provider::get_dom/parse_fh($fh, ",
$self->get_document_uri(), ")");
+ $xml_doc = $parser->parse_fh($fh, $self->get_document_uri());
+ };
+ if ($@) {
+ use bytes;
+ my $xmlstring = ${$self->get_strref()};
+ AxKit::Debug(8, "Provider::get_dom/parse_strref($xmlstring, ",
$self->get_document_uri(), ")");
+ $xml_doc = $parser->parse_string($xmlstring,
$self->get_document_uri()) ||
+ throw Apache::AxKit::Exception::Error(
+ -text => "XML::LibXML->parse_string returned nothing!"
+ );
+ }
+ }
return $xml_doc;
}
@@ -266,7 +264,7 @@
undef $pref_style;
}
- my @styles;
+ my @styles;
my $key = $self->key();
# need to extract the following from the XML file:
@@ -274,22 +272,22 @@
# DTD filename
# Root element name (including namespace)
# use three element array @$vals
-
- my ($doctype, $dtd, $root, $xml_styles) = $self->get_xml_info( $media,
$pref_style );
-
- $xml_styles = [] if $AxKit::Cfg->IgnoreStylePI();
-
- foreach my $style (@$xml_styles) {
- $style->{title} ||= '#default';
- }
- # Let GetMatchingProcessors to process the @$styles array
- {
- local $^W; # suppress "Use of uninitialized value" warnings
- AxKit::Debug(4, "Calling GetMatchingProcessors with ($media,
$pref_style, $doctype, $dtd, $root)");
- }
+ my ($doctype, $dtd, $root, $xml_styles) = $self->get_xml_info( $media,
$pref_style );
+
+ $xml_styles = [] if $AxKit::Cfg->IgnoreStylePI();
+
+ foreach my $style (@$xml_styles) {
+ $style->{title} ||= '#default';
+ }
+
+ # Let GetMatchingProcessors to process the @$styles array
+ {
+ local $^W; # suppress "Use of uninitialized value" warnings
+ AxKit::Debug(4, "Calling GetMatchingProcessors with ($media,
$pref_style, $doctype, $dtd, $root)");
+ }
- @styles = $AxKit::Cfg->GetMatchingProcessors($media, $pref_style,
$doctype, $dtd, $root, $xml_styles, $self);
+ @styles = $AxKit::Cfg->GetMatchingProcessors($media, $pref_style,
$doctype, $dtd, $root, $xml_styles, $self);
if ([EMAIL PROTECTED]) {
throw Apache::AxKit::Exception::Declined( reason => "No styles defined
for '$key'" );
@@ -325,34 +323,34 @@
}
sub get_xml_info{
- my ($self, $media, $pref_style ) = @_;
-
- # This is where the sniffing of the xml content happens.
-
- my $r = $self->apache_request();
- my @ret;
- eval{
- my $fh = $self->get_fh();
- my $pos = eval { tell $fh; };
- if($@) {
- # fh is not seekable, thus we must slurp file at this
point.
- undef $@;
- local($/) = undef;
- my $string = <$fh>;
- $r->pnotes('xml_string', $string);
- @ret = parse_xml_info( $r, undef, \$string, $media,
$pref_style);
- } else {
- # seekable.
- @ret = parse_xml_info( $r, $fh, undef, $media,
$pref_style);
- seek $fh, 0, $pos;
- }
- };
- if($@) {
- my $str_ref = $self->get_strref();
- $r->pnotes('xml_string', ${$str_ref});
- @ret = parse_xml_info( $r, undef, $str_ref, $media,
$pref_style);
- }
- return @ret;
+ my ($self, $media, $pref_style ) = @_;
+
+ # This is where the sniffing of the xml content happens.
+
+ my $r = $self->apache_request();
+ my @ret;
+ eval{
+ my $fh = $self->get_fh();
+ my $pos = eval { tell $fh; };
+ if($@) {
+ # fh is not seekable, thus we must slurp file at this point.
+ undef $@;
+ local($/) = undef;
+ my $string = <$fh>;
+ $r->pnotes('xml_string', $string);
+ @ret = parse_xml_info( $r, undef, \$string, $media, $pref_style);
+ } else {
+ # seekable.
+ @ret = parse_xml_info( $r, $fh, undef, $media, $pref_style);
+ seek $fh, 0, $pos;
+ }
+ };
+ if($@) {
+ my $str_ref = $self->get_strref();
+ $r->pnotes('xml_string', ${$str_ref});
+ @ret = parse_xml_info( $r, undef, $str_ref, $media, $pref_style);
+ }
+ return @ret;
}
sub parse_xml_info{
@@ -364,53 +362,53 @@
my $xml_styles = [];
my $vals = [];
- my @styles;
+ my @styles;
- if (defined &Apache::AxKit::Provider::xs_get_styles_fh) {
- AxKit::Debug(2, "using XS get_styles (libxml2)");
- my ($xs_styles, $doctype, $dtd, $root) = xs_get_styles($r, $fh,
$str_ref, $media, $pref_style);
- @$xml_styles = @$xs_styles unless $AxKit::Cfg->IgnoreStylePI();
- @$vals = ($doctype, $dtd, $root);
- }
- else {
- require XML::Parser;
+ if (defined &Apache::AxKit::Provider::xs_get_styles_fh) {
+ AxKit::Debug(2, "using XS get_styles (libxml2)");
+ my ($xs_styles, $doctype, $dtd, $root) = xs_get_styles($r, $fh,
$str_ref, $media, $pref_style);
+ @$xml_styles = @$xs_styles unless $AxKit::Cfg->IgnoreStylePI();
+ @$vals = ($doctype, $dtd, $root);
+ }
+ else {
+ require XML::Parser;
- AxKit::Debug(4, "get_styles: creating XML::Parser");
+ AxKit::Debug(4, "get_styles: creating XML::Parser");
- my $handlers = {
- Start => \&parse_start,
- Doctype => \&parse_dtd,
- $AxKit::Cfg->IgnoreStylePI() ? () : (Proc =>
\&parse_pi),
- };
+ my $handlers = {
+ Start => \&parse_start,
+ Doctype => \&parse_dtd,
+ $AxKit::Cfg->IgnoreStylePI() ? () : (Proc => \&parse_pi),
+ };
- my $xml_parser = XML::Parser->new(
- Namespaces => 1,
- ErrorContext => 2,
- Handlers => $handlers,
- );
+ my $xml_parser = XML::Parser->new(
+ Namespaces => 1,
+ ErrorContext => 2,
+ Handlers => $handlers,
+ );
- my $to_parse = $fh || ${$str_ref};
- #eval {
- # $to_parse = $provider->get_fh();
- #};
- #if ($@) {
- # $to_parse = ${ $provider->get_strref(); };
- #}
-
- AxKit::Debug(4, "get_styles: calling XML::Parser->parse()");
- $xml_parser->parse(
- $to_parse,
- XMLStyle_preferred => $pref_style,
- XMLStyle_media => $media,
- XMLStyle_style => $xml_styles,
- XMLStyle_vals => $vals,
- XMLStyle_style_screen => [],
- );
-
- AxKit::Debug(4, "get_styles: parse returned successfully");
- }
-
- return (@$vals, $xml_styles);
+ my $to_parse = $fh || ${$str_ref};
+ #eval {
+ # $to_parse = $provider->get_fh();
+ #};
+ #if ($@) {
+ # $to_parse = ${ $provider->get_strref(); };
+ #}
+
+ AxKit::Debug(4, "get_styles: calling XML::Parser->parse()");
+ $xml_parser->parse(
+ $to_parse,
+ XMLStyle_preferred => $pref_style,
+ XMLStyle_media => $media,
+ XMLStyle_style => $xml_styles,
+ XMLStyle_vals => $vals,
+ XMLStyle_style_screen => [],
+ );
+
+ AxKit::Debug(4, "get_styles: parse returned successfully");
+ }
+
+ return (@$vals, $xml_styles);
}
sub xs_get_styles {
Index: MANIFEST
===================================================================
--- MANIFEST (revision 419205)
+++ MANIFEST (working copy)
@@ -142,7 +142,8 @@
lib/Apache/AxKit/Language/XSP/Preload.pm
lib/Apache/AxKit/Language/XSP/SimpleTaglib.pm
lib/Apache/AxKit/Language/XSP/TaglibHelper.pm
-lib/Apache/AxKit/LibXMLSupport.pm
+lib/Apache/AxKit/LibXMLCallbacks.pm
+lib/Apache/AxKit/LibXML.pm
lib/Apache/AxKit/Makefile.PL
lib/Apache/AxKit/MediaChooser/WAPCheck.pm
lib/Apache/AxKit/Plugin/Fragment.pm