You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axkit-dev@xml.apache.org by ma...@apache.org on 2006/08/07 19:25:07 UTC

svn commit: r429404 - /xml/axkit/trunk/lib/Apache/AxKit/LibXMLCallbacks.pm

Author: matts
Date: Mon Aug  7 10:25:07 2006
New Revision: 429404

URL: http://svn.apache.org/viewvc?rev=429404&view=rev
Log:
Files forgotten from previous patch

Added:
    xml/axkit/trunk/lib/Apache/AxKit/LibXMLCallbacks.pm

Added: xml/axkit/trunk/lib/Apache/AxKit/LibXMLCallbacks.pm
URL: http://svn.apache.org/viewvc/xml/axkit/trunk/lib/Apache/AxKit/LibXMLCallbacks.pm?rev=429404&view=auto
==============================================================================
--- xml/axkit/trunk/lib/Apache/AxKit/LibXMLCallbacks.pm (added)
+++ xml/axkit/trunk/lib/Apache/AxKit/LibXMLCallbacks.pm Mon Aug  7 10:25:07 2006
@@ -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