NAME

XML::Compile::Cache - Cache compiled XML translators

INHERITANCE

XML::Compile::Cache
  is a XML::Compile::Schema

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);
use Data::Dumper;
print Dumper $reader->($xml);

# get the cached code ref for the writer, and use it
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);

METHODS

Constructors

XML::Compile::Cache->new(OPTIONS)

    Option          --Default
    allow_undeclared  <false>
    opts_readers      []
    opts_rw           []
    opts_writers      []
    prefixes          <smart>

    . allow_undeclared => BOOLEAN

      When true, you may call the reader or writer with types which were not registered with declare(). 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.

    . opts_readers => HASH|ARRAY-of-PAIRS

    . opts_rw => HASH|ARRAY-of-PAIRS

      Options added to both READERs and WRITERS. Options which are passed with declare() and opts_readers or opts_writers will overrule these.

    . opts_writers => HASH|ARRAY-of-PAIRS

    . prefixes => HASH|ARRAY-of-PAIRS

      Define prefix name to name-space mappings.

      These will also be automatically added to the writer options (opts_writers), as output_namespaces value, unless that already defines a name-space table.

Accessors

$obj->allowUndeclared([BOOLEAN])

    Whether it is permitted to create readers and writers which are not declared cleanly.

$obj->prefixes([PAIRS])

    Returns the HASH with prefix to name-space translations. You should not modify the returned HASH, but can provide PAIRS of additional prefix to namespace relations.

Administration

$obj->compileAll(['READER'|'WRITER'|'RW', [NAMESPACE]])

    Compile all the declared readers and writers (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 daemon process, where preparations can take as much time as they want to... and running should be as fast as possible.

$obj->declare('READER'|'WRITER'|'RW', TYPE|ARRAY-of-TYPES, OPTIONS)

    Register that the indicated TYPE (or TYPES) may be used, and needs to be translated with the OPTIONS (either specified as ARRAY or LIST). Specify whether it may get used as READER, WRITER, or both (RW). If the READER and WRITER need different options, then you need to declare them seperately; in that case you cannot use RW.

    The TYPE should be understood by findName(), so may be prefixed.

    example:

    $cache->declare(READER => 'pref:count', sloppy_integers => 1)
          ->declare(RW     => '{myns}mylocal');
    
    $cache->declare(WRITER => [ 'xsd:int', '{http://}aap' ]);

$obj->findName(NAME)

    Understand the name specification. The NAME can be a full type (like '{namespace}localname') or a prefixed type (like 'myms:localname'). The prefixes must be defined with new(prefixes).

$obj->printIndex([FILEHANDLE], OPTIONS)

    Option       --Default
    show_declared  <true>

    . show_declared => BOOLEAN

      Add an indicator to each line, about whether readers and writers are declare for the type. Declared readers and writers will show flags r and w respectively. Compiled readers and writers carry a R and/or W.

Producers

$obj->reader(TYPE|NAME, OPTIONS)

    Returns the reader for the TYPE, which may be specified as prefixed NAME, see findName(). OPTIONS are only permitted if new(allow_undeclared) is true, and the same as the previous call to this method.

$obj->writer(TYPE)

SEE ALSO

This module is part of XML-Compile-Cache distribution version 0.10, built on June 06, 2008. Website: http://perl.overmeer.net/xml-compile/

All modules in this suite: "XML::Compile", "XML::Compile::SOAP", "XML::Compile::SOAP::Daemon", "XML::Compile::Tester", "XML::Compile::Cache", "XML::Compile::Dumper".

Please post questions or ideas to http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/xml-compile For life contact with other developers, visit the #xml-compile channel on irc.perl.org.

LICENSE

Copyrights 2008 by Mark Overmeer. For other contributors see ChangeLog.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See http://www.perl.com/perl/misc/Artistic.html

1 POD Error

The following errors were encountered while parsing the POD:

Around line 206:

alternative text 'http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/xml-compile' contains non-escaped | or /