From: Mike Rylander Date: Tue, 10 Apr 2012 20:30:30 +0000 (-0400) Subject: Utility method for turning the output of a detail request into xml -- just a start... X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=7cf8d33af24e645bdbd0cc0d90388d130ad6aa31;p=evergreen%2Fequinox.git Utility method for turning the output of a detail request into xml -- just a start, though Signed-off-by: Mike Rylander --- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Collections.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Collections.pm index e5da73cbc1..1fe3992117 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Collections.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Collections.pm @@ -11,6 +11,8 @@ use OpenILS::Utils::CStoreEditor qw/:funcs/; use OpenILS::Event; use OpenILS::Const qw/:const/; my $U = "OpenILS::Application::AppUtils"; +use XML::LibXML; +use Scalar::Util 'blessed'; # -------------------------------------------------------------- @@ -788,6 +790,44 @@ sub transaction_details { return \@data; } +sub detailToXML { + my $data = shift; + + my $dom = XML::LibXML::Document->new; + my $root = $dom->createElement( 'Collections' ); + $dom->setDocumentElement( $root ); + + for my $row (@$data) { + my $blob = $dom->createElement( 'User' ); + $root->appendChild( $blob ); + + my $node = $row->{usr}->toXML; + next unless $node; + + $node = $node->documentElement; + $dom->adoptNode( $node ); + $blob->appendNode( $node ); + + my $trans = $dom->createElement( 'Transactions' ); + $blob->appendChild( $trans ); + + for my $xact ( + @{$row->{transactions}->{circulations}}, + @{$row->{transactions}->{reservations}}, + @{$row->{transactions}->{grocery}} ) { + + $node = $xact->toXML; + next unless $node; + + $node = $node->documentElement; + $dom->adoptNode( $node ); + $trans->appendNode( $node ); + } + } + + return $dom; +} + sub flesh_payment { my $e = shift; my $p = shift;