->load_xml and XML::LibXML::InputCallback

Dave Cardwell <[email protected]>
Newsgroups gmane.comp.lang.perl.xml
Message-ID <[email protected]>
Hello there,

I recently upgraded to XML::LibXML 1.70 and noticed the addition of
the ->load_xml method.

When using this in conjunction with the `location` parameter to load
an external file it seems to ignore the InputCallback that was
previously working fine with the ->parse_file method.

I have attached a short test case to this e-mail. When the file is
read in with ->parse_file a warning is generated in the InputCallback,
however the warning is not triggered with ->load_xml. Should it be, or
am I missing something?

-- 
Best wishes,
Dave Cardwell.

http://davecardwell.co.uk/
http://cardwellit.com/

_______________________________________________
Perl-XML mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
testcase.pl (application/octet-stream, 671 B)
#!/usr/bin/perl -wT

use strict;
use warnings;

use XML::LibXML;

die 'This test case is for XML::LibXML v1.70'
    unless $XML::LibXML::VERSION eq '1.70';

my $input_callbacks = XML::LibXML::InputCallback->new();
$input_callbacks->register_callbacks([
    sub { 1 },
    sub { warn 'Input callback used'; open my $fh, '<', shift; return $fh; },
    sub { my $buffer; read(shift, $buffer, shift); return $buffer; },
    sub { close shift },
]);

my $xml_parser = XML::LibXML->new();
$xml_parser->input_callbacks($input_callbacks);

warn "->parse_file:\n";
$xml_parser->parse_file('testcase.xml');

warn "->load_xml:\n";
$xml_parser->load_xml(location => 'testcase.xml');
testcase.xml (text/xml, 46 B)
<?xml version="1.0" encoding="utf-8"?>

<foo/>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.