XML-Compile-Cache-1.01/0000755000175000001440000000000012262306406015201 5ustar00markovusers00000000000000XML-Compile-Cache-1.01/META.yml0000644000175000001440000000110112262306406016443 0ustar00markovusers00000000000000--- abstract: 'Cache compiled XML translators' 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-Cache no_index: directory: - t - inc requires: Log::Report: 0.19 Test::More: 0.54 XML::Compile: 1.41 XML::Compile::Tester: 0.02 XML::LibXML::Simple: 0.13 version: 1.01 XML-Compile-Cache-1.01/xt/0000755000175000001440000000000012262306406015634 5ustar00markovusers00000000000000XML-Compile-Cache-1.01/xt/99pod.t0000644000175000001440000000041212262306405016761 0ustar00markovusers00000000000000#!/usr/bin/perl use warnings; use strict; use Test::More; BEGIN { eval "use Test::Pod 1.00"; plan skip_all => "Test::Pod 1.00 required for testing POD" if $@; plan skip_all => "devel home uses OODoc" if $ENV{MARKOV_DEVEL}; } all_pod_files_ok(); XML-Compile-Cache-1.01/Makefile.PL0000644000175000001440000000166412262306405017161 0ustar00markovusers00000000000000use ExtUtils::MakeMaker; use 5.008; WriteMakefile ( NAME => 'XML::Compile::Cache' , VERSION => '1.01' , PREREQ_PM => { XML::Compile => '1.41' , XML::Compile::Tester => 0.02 , XML::LibXML::Simple => 0.13 , Log::Report => 0.19 , Test::More => 0.54 } , EXE_FILES => [] , AUTHOR => 'Mark Overmeer' , ABSTRACT => 'Cache compiled XML translators' , LICENSE => 'perl' ); ### used by oodist during production of distribution sub MY::postamble { <<'__POSTAMBLE' } # for DIST EXTENDS = ../XMLCompile:../XMLSimple RAWDIR = ../public_html/xml-compile-cache/raw DISTDIR = ../public_html/xml-compile-cache/source LICENSE = artistic SKIP_LINKS = XML::LibXML # for POD FIRST_YEAR = 2008 EMAIL = perl@overmeer.net WEBSITE = http://perl.overmeer.net/xml-compile/ PODTAIL = ../XML-shared-podtail __POSTAMBLE XML-Compile-Cache-1.01/README0000644000175000001440000000147612262306405016070 0ustar00markovusers00000000000000=== README for XML-Compile-Cache version 1.01 = Generated on Sun Jan 5 17:49:09 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-Cache-1.01.tar.gz tar -xf XML-Compile-Cache-1.01.tar cd XML-Compile-Cache-1.01 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-Cache-1.01/ Please report problems to http://rt.cpan.org/Dist/Display.html?Queue=XML-Compile-Cache XML-Compile-Cache-1.01/ChangeLog0000644000175000001440000001332712262306405016760 0ustar00markovusers00000000000000 ==== version history of XML::Compile::Cache version 1.01: Sun Jan 5 17:47:17 CET 2014 Changes: - xsiType() renamed to addXsiType(), old name still available Improvements: - bit more docs on addPrefixes() version 1.00: Mon Oct 14 23:15:46 CEST 2013 Improvements: - bump version numbers back into two-digits, because FreeBSD ports doesn't like it. [Patrick Powell] version 0.995: Sat Aug 10 00:16:59 CEST 2013 Fixes: - ::new(prefixes) did not overrule the prefixes from the schema file. Improvements: - alias new ::addPrefixes() to ::prefixes() for more consistent naming. - new ::Cache::byPrefixTable() version 0.994: Mon May 13 12:17:51 CEST 2013 Fixes: - compileAll() used declared parameters twice. version 0.993: Fri May 3 15:11:16 CEST 2013 Improvements: - spell-fix rt.cpan.org#82952 [Joenio Marques da Costa] - new learnPrefixes($node) - prefixed() now also callable with separate ($ns, $local) version 0.992: Fri Aug 31 00:25:48 CEST 2012 Improvements: - support xsiType() with 'AUTO', discovered by [Ciaran Deignan] - remove dependency to Test::POD version 0.991: Fri May 6 10:09:18 CEST 2011 Fixes: - prefix declaration list which starts with a default ('') prefix. version 0.99: Wed Apr 27 17:09:44 CEST 2011 Fixes: - be able to use newly defined prefixes immediately in xsiTable. Improvements: - report missing action parameter to template(), common mistake - add method addCompileOptions() - add method anyElement() version 0.98: Wed Dec 22 16:39:52 CET 2010 Improvements: - compileAll() now also knows of READERS/WRITERS as alternative (better readible) alternatives of READER/WRITER. - new accessor typemap() to add typemaps nicer. - new accessor xsiTypes() to add xsi_type definitions nicer. - typemaps and xsi_types do now accept prefixed types. version 0.97: Thu Sep 30 17:09:34 CEST 2010 Fixes: - template() merging options Improvements: - trace: declare includes why: READER/WRITER/RW - prefixed() will return undef not error when there is no prefix defined for the namespace. version 0.96: Thu Jun 10 16:05:05 CEST 2010 Fixes: - do not spit warnings when "allow_undeclared" and the parameter list contains undefined values. Reported by [Robin V.] - memory leak, caused by rewrite of any_element rt.cpan.org#57943 [Jacob Bunk Nielsen] - repair tests, to work with changed interface of Test::More. [cpantesters] - fix docs: compileClient() does not accept parameters for compile() because those settings cannot be passed to elements which are magically understood via "any_element => 'ATTEMPT'" Problem reported by [Knut Arne Bjørndal] version 0.95: Thu Apr 1 11:36:42 CEST 2010 Changes: - handling of compile() and mergeCompileOptions() Improvements: - support for compileType() version 0.94: Tue Mar 2 09:18:38 CET 2010 Fixes: - default need for compileAll() not handled. - merging of prefixes parameter. version 0.93: Fri Dec 25 01:05:59 CET 2009 Fixes: - "super option" any_element other than ATTEMPT got ignored, although available as explicit reader/writer/rw options. - template: use of key_rewrite Improvements: - add any_element choice "SLOPPY". This required XML::LibXML::Simple - some text improvements. version 0.92: Thu May 28 11:51:50 CEST 2009 Improvements: - error if template() and compile() are called with too few parameters. - trace when new prefixes get defined. - new method prefixed() version 0.91: Thu Feb 12 11:27:40 CET 2009 Fixes: - cleanup of multiple hooks was broken. - do not use /bin/pwd in t/pod.t - fix tests wrt changes in XML::Compile 1.01 version 0.90: Wed Jan 21 11:03:19 CET 2009 Fixes: - be more careful that opt_* flags may be passed as either ARRAY or HASH. Improvements: - template: accept prefixed types. - accept prefixes in type-based hooks, for compile(), template() and addHook(). - prefixes() accepts HASH and ARRAY as well version 0.14: Mon Dec 29 10:59:22 CET 2008 Fixes: - any_element ATTEMPT needs to follow keyRewrite rules - _createReader() and _createWriter() missed type dependend options in merge. - accept namespace-less names in findName() Improvements: - one namespace may have multiple prefixes, only the first is used in the output. - type-based hooks can now also use prefixes. - the options used for X::C::Schema::compile() are not merged in a very clever way. - findName() can now also translates prefixes into namespaces, not only translate prefixed types. Report available choices when an unknown prefix is used. - findName() allows '-' in prefix. - new method prefix() to lookup a prefix. One namespace can have multiple prefixes, of which the first is used for the output. - new method prefixFor() to lookup prefix for URI. - support findName() with compile() - when an undeclared reader or writer is produced with different options, then which will not produce an error but just avoids the use of the cached code. - new method mergeCompileOptions() version 0.13: Fri Aug 1 13:21:09 CEST 2008 Changes: - requires XML::Compile 0.91 for options to ::Schema::new(any_element) and any_attribute. - rewrote prefix handling to be compatible with XML::Compile::Schema improvements. Improvements: - any_element and any_attribute READER option 'CONVERT' - findName() accepts default name-space in search. version 0.12: Tue Jul 8 13:25:05 CEST 2008 Changes: - require XML::Compile 0.87 for rename of option output_namespaces, replaces by 'prefixes'. Improvements: - merge prefixes with ::Schema base administration, to permit key_rewrite. version 0.11: Thu Jun 12 14:36:40 CEST 2008 Improvements - include XML::Compile::Schema method in the docs. - added more docs version 0.10: Fri Jun 6 16:01:16 CEST 2008 Initial version. XML-Compile-Cache-1.01/lib/0000755000175000001440000000000012262306406015747 5ustar00markovusers00000000000000XML-Compile-Cache-1.01/lib/XML/0000755000175000001440000000000012262306406016407 5ustar00markovusers00000000000000XML-Compile-Cache-1.01/lib/XML/Compile/0000755000175000001440000000000012262306406017777 5ustar00markovusers00000000000000XML-Compile-Cache-1.01/lib/XML/Compile/Cache.pod0000644000175000001440000004110612262306405021507 0ustar00markovusers00000000000000=encoding utf8 =head1 NAME XML::Compile::Cache - Cache compiled XML translators =head1 INHERITANCE XML::Compile::Cache is a XML::Compile::Schema is a XML::Compile =head1 SYNOPSIS my $cache = XML::Compile::Cache->new(...); $cache->declare('READER', $type, @options); $cache->declare(RW => \@types, @options); $cache->declare(WRITER => $type, \@options); $cache->compileAll; $cache->compileAll('RW'); # get the cached code ref for the reader my $reader = $cache->reader($type, @opts); use Data::Dumper; print Dumper $reader->($xml); # get the cached code ref for the writer, and use it my $doc = XML::LibXML::Document->new('1.0', 'UTF-8'); my $xml = $cache->writer($type)->($doc, $perl); print $xml->toString(1); # use the base-class uncached, the XML::Compile::Schema my $do = $cache->compile(READER => $type, @opts); =head1 DESCRIPTION See L. =head1 METHODS See L. =head2 Constructors See L. =over 4 =item XML::Compile::Cache-EB(OPTIONS) -Option --Defined in --Default allow_undeclared any_element 'SKIP_ALL' block_namespace XML::Compile::Schema [] hook XML::Compile::Schema undef hooks XML::Compile::Schema [] ignore_unused_tags XML::Compile::Schema key_rewrite XML::Compile::Schema [] opts_readers [] opts_rw [] opts_writers [] parser_options XML::Compile prefixes schema_dirs XML::Compile undef typemap {} xsi_type {} =over 2 =item allow_undeclared => BOOLEAN When true, you may call the reader or writer with types which were not registered with L. In that case, the reader or writer may also get options passed for the compiler, as long as they are consistent over each use of the type. =item any_element => CODE|'TAKE_ALL'|'SKIP_ALL'|'ATTEMPT'|'SLOPPY' See L. =item block_namespace => NAMESPACE|TYPE|HASH|CODE|ARRAY =item hook => ARRAY-WITH-HOOKDATA | HOOK =item hooks => ARRAY-OF-HOOK =item ignore_unused_tags => BOOLEAN|REGEXP =item key_rewrite => HASH|CODE|ARRAY-of-HASH-and-CODE =item opts_readers => HASH|ARRAY-of-PAIRS =item opts_rw => HASH|ARRAY-of-PAIRS Options added to both READERs and WRITERS. Options which are passed with L and C or C will overrule these. See L. =item opts_writers => HASH|ARRAY-of-PAIRS =item parser_options => HASH|ARRAY =item prefixes => HASH|ARRAY-of-PAIRS Define prefix name to name-space mappings. Passed to L for each reader and writer, but also used to permit L to accept types which use a prefix. Specify an ARRAY of (prefix, name-space) pairs, or a HASH which maps name-spaces to prefixes (HASH order is reversed from ARRAY order!) When you wish to collect the results, like usage counts, of the translation processing, you will need to specify a HASH. prefixes => [ mine => $myns, your => $yourns ] prefixes => { $myns => 'mine', $yourns => 'your' } # the previous is short for: prefixes => { $myns => [ uri => $myns, prefix => 'mine', used => 0 ] , $yourns => [ uri => $yourns, prefix => 'your', ...] } =item schema_dirs => DIRECTORY|ARRAY-OF-DIRECTORIES =item typemap => HASH|ARRAY =item xsi_type => HASH|ARRAY =back =back =head2 Accessors See L. =over 4 =item $obj-EB(HOOKDATA|HOOK|undef) See L =item $obj-EB(HOOK, [HOOK, ...]) See L =item $obj-EB(PREDEF|CODE|HASH, ...) See L =item $obj-EB(DIRECTORIES|FILENAME) =item XML::Compile::Cache-EB(DIRECTORIES|FILENAME) See L =item $obj-EB(XML, OPTIONS) See L =item $obj-EB(PAIR) See L =item $obj-EB(PAIRS) See L =item $obj-EB([HASH|ARRAY|LIST]) [1.01] add global xsi_type declarations. Returns the xsiType set. The ARRAY or LIST contains pairs, just like the HASH. The value component can be 'AUTO' to automatically detect the C extensions. This does only work for complex types. =item $obj-EB([BOOLEAN]) Whether it is permitted to create readers and writers which are not declared cleanly. =item $obj-EB('ATTEMPT'|'SLOPPY'|'SKIP_ALL'|'TAKE_ALL'|CODE) [as method since 0.99] How to process ANY elements, see also L. Reader: C will convert all any elements, applying the reader for each element found. When an element is not found in a schema, it will be included as XML::LibXML::Element node. [0.93] Reader: With C, first automatic typed conversion is attempted. But is the type is not known, L is called to the resque. =item $obj-EB(NAMESPACE|TYPE|HASH|CODE|ARRAY) See L =item $obj-EB([READER|WRITER]) See L =item $obj-EB([HASH|ARRAY|PAIRS]) [0.98] Add global knowledge on typemaps. Returns the typemap. =item $obj-EB(SCHEMA, [SCHEMA]) See L =back =head2 Prefix management The cache layer on top of L adds smart use of prefixes. Of course, smartness comes with a small performance cost, but the code gets much cleaner. =over 4 =item $obj-EB([PAIRS|ARRAY|HASH]) The X::C logic does auto-detect prefix/namespaces combinations from the XML, but does not search extensively for namespace declarations. Also, sometimes the same namespace is used with different prefixes. Sometimes, the same prefix is used for different namesapces. To complete the list, or control the actual prefix being used, you explicitly declare combinations. The B to add prefixes is via L, which will give your names preference over the names found in the schema's which get loaded. For instance, use C<< ::WSDL->new(prefixes => [ $prefix => $ns ] >> [0.995] Returns the HASH with prefix to name-space translations. You should not modify the returned HASH: new PAIRS of prefix to namespace relations can be passed as arguments. [0.14] If a name-space appears for the second time, then the new prefix will be recognized by L, but not used in the output. When the prefix already exists for a different namespace, then an error will be casted. [0.90] You may also provide an ARRAY of pairs or a HASH. =item $obj-EB(NODE) [0.993] Take all the prefixes defined in the NODE, and XML::LibXML::Element. This is not recursive: only on those defined at the top NODE. =item $obj-EB(PREFIX) Lookup a prefix definition. This returns a HASH with namespace info. =item $obj-EB(URI) Lookup the preferred prefix for the URI. =item $obj-EB(TYPE|(NAMESPACE,LOCAL)) Translate the fully qualified TYPE into a prefixed version. Will produce undef if the namespace is unknown. [0.993] When your TYPE is not in packed form, you can specify a namespace and LOCAL type name as separate arguments. example: print $schema->prefixed($type) || $type; print $schema->prefixed($ns, $local); =item $obj-EB([PARAMS]) Return prefixes table. The PARAMS are deprecated since [0.995], see L. =back =head2 Compilers The name of this module refers to its power to administer compiled XML encoders (writers) and decoders (readers). This means that your program only need to pass on a ::Cache object (for instance a XML::Compile::WSDL11, not a CODE reference for each compiled translator. See L. =over 4 =item $obj-EB(['READERS'|'WRITERS'|'RW'], OPTIONS) [0.99] You may provide global compile options with L, C and C, but also later using this method. =item $obj-EB(('READER'|'WRITER'), TYPE, OPTIONS) See L =item $obj-EB(['READERS'|'WRITERS'|'RW', [NAMESPACE]]) Compile all the declared readers and writers with the default 'RW'). You may also select to pre-compile only the READERS or only the WRITERS. The selection can be limited further by specifying a NAMESPACE. By default, the processors are only compiled when used. This method is especially useful in a B, where preparations can take as much time as they want to... and running should be as fast as possible. =item $obj-EB(NODE|REF-XML-STRING|XML-STRING|FILENAME|FILEHANDLE|KNOWN) =item XML::Compile::Cache-EB(NODE|REF-XML-STRING|XML-STRING|FILENAME|FILEHANDLE|KNOWN) See L =item $obj-EB(OPTIONS) =item XML::Compile::Cache-EB(OPTIONS) See L =item $obj-EB(TYPE|NAME, OPTIONS) Returns the reader CODE for the TYPE or NAME (see L). OPTIONS are only permitted if L is true, and the same as the previous call to this method. The reader will be compiled the first time that it is used, and that same CODE reference will be returned each next request for the same TYPE. Call L to have all readers compiled by force. example: my $schema = XML::Compile::Cache->new(\@xsd, prefixes => [ gml => $GML_NAMESPACE ] ); my $data = $schema->reader('gml:members')->($xml); my $getmem = $schema->reader('gml:members'); my $data = $getmem->($xml); =item $obj-EB