Apache-Solr
view release on metacpan or search on metacpan
lib/Apache/Solr/XML.pm view on Meta::CPAN
# This code is part of Perl distribution Apache-Solr version 1.12.
# The POD got stripped from this file by OODoc version 3.06.
# For contributors see file ChangeLog.
# This software is copyright (c) 2012-2026 by Mark Overmeer.
# This is free software; you can redistribute it and/or modify it under
# the same terms as the Perl 5 programming language system itself.
# SPDX-License-Identifier: Artistic-1.0-Perl OR GPL-1.0-or-later
package Apache::Solr::XML;{
our $VERSION = '1.12';
}
use base 'Apache::Solr';
use warnings;
use strict;
use Log::Report qw/solr/;
use Apache::Solr::Result ();
use XML::LibXML::Simple ();
use HTTP::Message ();
use HTTP::Request ();
use Scalar::Util qw/blessed/;
use Data::Dumper;
$Data::Dumper::Indent = 1;
$Data::Dumper::Quotekeys = 0;
# See the XML::LibXML::Simple manual page
my @xml_decode_config = (
ForceArray => [],
ContentKey => '_',
KeyAttr => [],
);
#--------------------
sub init($)
{ my ($self, $args) = @_;
$args->{format} ||= 'XML';
$self->SUPER::init($args);
$self->{ASX_simple} = XML::LibXML::Simple->new(@xml_decode_config);
$self;
}
#--------------------
sub xmlsimple() { $_[0]->{ASX_simple} }
#--------------------
sub _select($$)
{ my ($self, $args, $params) = @_;
my $endpoint = $self->endpoint('select', params => $params);
my $result = Apache::Solr::Result->new(%$args, params => $params, endpoint => $endpoint, core => $self);
$self->request($endpoint, $result);
$result;
}
sub _extract($$$)
{ my ($self, $params, $data, $ct) = @_;
my $endpoint = $self->endpoint('update/extract', params => $params);
my $result = Apache::Solr::Result->new(params => $params, endpoint => $endpoint, core => $self);
$self->request($endpoint, $result, $data, $ct);
$result;
}
sub _add($$$)
{ my ($self, $docs, $attrs, $params) = @_;
$attrs ||= {};
$params ||= [];
my $doc = XML::LibXML::Document->new('1.0', 'UTF-8');
my $add = $doc->createElement('add');
$add->setAttribute($_ => $attrs->{$_}) for sort keys %$attrs;
$add->addChild($self->_doc2xml($doc, $_))
for @$docs;
$doc->setDocumentElement($add);
( run in 1.631 second using v1.01-cache-2.11-cpan-acf6aa7dc9e )