XML-Compile-Dumper-0.14/0000755000175000001440000000000012267712251015441 5ustar00markovusers00000000000000XML-Compile-Dumper-0.14/META.yml0000644000175000001440000000120312267712251016706 0ustar00markovusers00000000000000--- abstract: 'Remember precompiled XML processors' author: - 'Mark Overmeer' build_requires: ExtUtils::MakeMaker: 0 configure_requires: ExtUtils::MakeMaker: 0 dynamic_config: 1 generated_by: 'ExtUtils::MakeMaker version 6.64, CPAN::Meta::Converter version 2.120630' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 name: XML-Compile-Dumper no_index: directory: - t - inc requires: Data::Dump::Streamer: 2.08 Log::Report: 0.09 Math::BigInt: 1.77 Test::More: 0.54 Test::Pod: 1.00 XML::Compile: 0.64 XML::Compile::Tester: 0.01 XML::LibXML: 1.63 version: 0.14 XML-Compile-Dumper-0.14/Makefile.PL0000644000175000001440000000215012267710142017406 0ustar00markovusers00000000000000use ExtUtils::MakeMaker; use 5.008; WriteMakefile ( NAME => 'XML::Compile::Dumper' , VERSION => '0.14' , PREREQ_PM => { XML::LibXML => 1.63 , Data::Dump::Streamer => 2.08 , XML::Compile => 0.64 , XML::Compile::Tester => 0.01 , Math::BigInt => 1.77 , Log::Report => 0.09 , Test::More => 0.54 , Test::Pod => '1.00' } , AUTHOR => 'Mark Overmeer' , ABSTRACT => 'Remember precompiled XML processors' , LICENSE => 'perl' ); ### used by oodist during production of distribution sub MY::postamble { <<'__POSTAMBLE' } # for DIST RAWDIR = ../public_html/xml-compile-dumper/raw DISTDIR = ../public_html/xml-compile-dumper/source LICENSE = artistic FIRST_YEAR = 2007 EMAIL = perl@overmeer.net WEBSITE = http://perl.overmeer.net/xml-compile/ PODTAIL = ../XML-shared-podtail # for HTML HTML_OUTPUT = ../public_html/xml-compile/html HTML_DOCROOT = /xml-compile/html HTML_PACKAGE = ../public_html/xml-compile/htmlpkg __POSTAMBLE XML-Compile-Dumper-0.14/README0000644000175000001440000000150412267710142016316 0ustar00markovusers00000000000000=== README for XML-Compile-Dumper version 0.14 = Generated on Wed Jan 22 10:33:22 2014 by OODoc 2.01 There are various ways to install this module: (1) if you have a command-line, you can do: perl -MCPAN -e 'install ' (2) if you use Windows, have a look at http://ppm.activestate.com/ (3) if you have downloaded this module manually (as root/administrator) gzip -d XML-Compile-Dumper-0.14.tar.gz tar -xf XML-Compile-Dumper-0.14.tar cd XML-Compile-Dumper-0.14 perl Makefile.PL make # optional make test # optional make install For usage, see the included manual-pages or http://search.cpan.org/dist/XML-Compile-Dumper-0.14/ Please report problems to http://rt.cpan.org/Dist/Display.html?Queue=XML-Compile-Dumper XML-Compile-Dumper-0.14/ChangeLog0000644000175000001440000000152312267710142017211 0ustar00markovusers00000000000000=== version history of XML::Compile::Dumper All changes made by Mark Overmeer, unless explicitly noted differently. version 0.14: Wed Jan 22 10:32:56 CET 2014 Fix: - add Log::Report to some namespaces - add Data::Dumper::Streamer ':undump' to the output Improvements: - change documentation style. version 0.13: Fri Mar 26 11:14:56 CET 2010 Fix: - name of test file in MANIFEST version 0.12: Fri Mar 26 10:14:04 CET 2010 Fixes: - do not use /bin/pwd in t/99pod.t - add "use Log::Report" to the output [Robin V.] version 0.11: Mon Nov 24 13:47:18 CET 2008 Changes: - requires XML::Compile::Tester - correct abstract version 0.10: Sun Dec 23 10:39:04 CET 2007 - split-off from XML::Compile, to + reduce the number of dependencies for XML::Compile + to give Yves some time to adapt Data::Dump::Streamer to perl5.10 XML-Compile-Dumper-0.14/lib/0000755000175000001440000000000012267712251016207 5ustar00markovusers00000000000000XML-Compile-Dumper-0.14/lib/XML/0000755000175000001440000000000012267712251016647 5ustar00markovusers00000000000000XML-Compile-Dumper-0.14/lib/XML/Compile/0000755000175000001440000000000012267712251020237 5ustar00markovusers00000000000000XML-Compile-Dumper-0.14/lib/XML/Compile/Dumper.pm0000644000175000001440000000615512267712250022037 0ustar00markovusers00000000000000# Copyrights 2007-2014 by [Mark Overmeer]. # For other contributors see ChangeLog. # See the manual pages for details on the licensing terms. # Pod stripped from pm file by OODoc 2.01. use warnings; use strict; package XML::Compile::Dumper; our $VERSION = '0.14'; use Log::Report 'xml-compile', syntax => 'SHORT'; use Data::Dump::Streamer; use POSIX qw/asctime/; use IO::File; # I have no idea why the next is needed, but without it, the # tests are failing. use XML::Compile::Schema; sub new(@) { my ($class, %opts) = @_; (bless {}, $class)->init(\%opts); } sub init($) { my ($self, $opts) = @_; my $fh = $opts->{filehandle}; unless($fh) { my $fn = $opts->{filename} or error __x"either filename or filehandle required"; $fh = IO::File->new($fn, '>:utf8') or fault __x"cannot write to {filename}", filename => $fn; } $self->{XCD_fh} = $fh; my $package = $opts->{package} or error __x"package name required"; $self->header($fh, $package); $self; } sub close() { my $self = shift; my $fh = $self->file or return 1; $self->footer($fh); delete $self->{XCD_fh}; $fh->close; } sub DESTROY() { my $self = shift; $self->close; } sub file() {shift->{XCD_fh}} sub header($$) { my ($self, $fh, $package) = @_; my $date = asctime localtime; $date =~ s/\n.*//; my $xc_version = $XML::Compile::VERSION || '(devel)'; $fh->print( <<__HEADER ); #crash # This module has been generated using # XML::Compile $xc_version # Data::Dump::Streamer $Data::Dump::Streamer::VERSION # Created with a script # named $0 # on $date use warnings; no warnings 'once'; no strict; # sorry package $package; use base 'Exporter'; use XML::LibXML (); use Log::Report; use Data::Dump::Streamer ':undump'; our \@EXPORT; # We will need these modules { package XML::Compile::Translate::Reader; use Log::Report; ; package XML::Compile::Translate::Writer; use Log::Report; ; package XML::Compile::Transport::SOAPHTTP; use Log::Report; ; package XML::Compile::Transport; use Log::Report; } __HEADER } sub freeze(@) { my $self = shift; error "freeze needs PAIRS or a HASH" if (@_==1 && ref $_[0] ne 'HASH') || @_ % 2; error "freeze can only be called once" if $self->{XCD_freeze}++; my (@names, @data); if(@_==1) # Hash { my $h = shift; @names = keys %$h; @data = values %$h; } else # Pairs { while(@_) { push @names, shift; push @data, shift; } } my $fh = $self->file; my $export = join "\n ", sort @names; $fh->print("push \@EXPORT, qw/\n $export/;\n\n"); Data::Dump::Streamer->new->To($fh)->Data(@data)->Out; for(my $i = 0; $i < @names; $i++) { ref $data[$i] eq 'CODE' or error __x"value with '{label}' is not a code reference" , label => $names[$i]; my $code = '$CODE'.($i+1); $fh->print("*${names[$i]} = $code;\n"); } } sub footer($) { my ($self, $fh) = @_; $fh->print( "\n1;\n" ); } 1; XML-Compile-Dumper-0.14/lib/XML/Compile/Dumper.pod0000644000175000001440000001041612267712250022200 0ustar00markovusers00000000000000=encoding utf8 =head1 NAME XML::Compile::Dumper - Remember precompiled XML processors =head1 SYNOPSIS # create readers and writers or soap things my $reader = $schema->compile(READER => '{myns}mytype'); my $writer = $schema->compile(WRITER => ...); # then dump them into a package my $dumper = XML::Compile::Dumper->new (package => 'My::Package', filename => 'My/Package.pm'); $dumper->freeze(foo => $reader, bar => $writer); $dumper->close; # later, they can get recalled using use My::Package; my $hash = foo($xml); my $doc = bar($doc, $xml); =head1 DESCRIPTION This module simplifies the task of saving and loading pre-compiled translators. Schema's can get huge, and when you are not creating a daemon to do the XML communication, you may end-up compiling and interpreting these large schemas often, just to be able to process simple data-structures. Based on the excellent module Data::Dump::Streamer, this module helps you create standard Perl packages which contain the reader and writer code references. WARNING: this feature was introduced in release 0.17. Using perl 5.8.8, libxml 2.6.26, XML::LibXML 2.60, and Data::Dump::Streamer 2.03, Perl complains about C<"PmmREFCNT_dec: REFCNT decremented below 0! during global destruction."> when the tests are run. This bug can be anywhere. Therefore, these tests are disabled by default in t/TestTools.pm. If you have time, could you please run the tests with C<$skip_dumper = 0;> and report the results to the author? =head1 METHODS =head2 Constructors =over 4 =item $obj-EB() Finalize the produced file. This will be called automatically if the objects goes out-of-scope. =item XML::Compile::Dumper-EB(%options) Create an object which will collect the information for the output file. You have to specify either a C or a C. A filehandle will be closed after processing. -Option --Default filehandle undef filename undef package =over 2 =item filehandle => C =item filename => FILENAME The file will be written using utf8 encoding, using IO::File. If you want something else, open your filehandle first, and provide that as argument. =item package => PACKAGE The name-space which will be used: it will produce a C line in the output. =back =back =head2 Accessors =over 4 =item $obj-EB() Returns the output file-handle, which you may use to add extensions to the module. =back =head2 Producers =over 4 =item $obj-EB