
XML::RelaxNG::Compact::PXB - create perl XML (RelaxNG Compact) data binding API

Version 0.09

The instance of this class is capable of generating the API tree of the perl objects based on XML (RelaxNG compact) schema described as perl data structures. If you have bunch of XML schemes ( and able to convert them into RelaxNG Compact ) and hate to waste your time by writing DOM tree walking code then this module may help you. Of course POD will be created automatically as well. Also, it will build the tests suit automatically as well and provide perltidy and perlcritic config files for you to assure the absence of problems in your API. The Perl::Critic test will be performed as part of the tests suit.
See XML::RelaxNG::Compact::DataModel for more details and examples.

###
use XML::RelaxNG::Compact::PXB;
# express your schema
my $subelement = { 'attrs' => {value => 'scalar', type => 'scalar', port => 'scalar', xmlns => 'nsid2'},
elements => [],
text => 'unless:value',
};
my $model = = { 'attrs' => {id => 'scalar', type => 'scalar', xmlns => 'nsid'},
elements => [
[subelement => $subelement ]
],
};
# define Namespace registry for your schemes
my $nsreg = { 'nsid' => 'http://nsid/URI', 'nsid2' => 'http://nsid2/URI'};
# create API builder with your desired parameters
#
my $api_builder = XML::RelaxNG::Compact::PXB->new({
top_dir => "/topdir/",
nsregistry => $nsreg,
datatypes_root => "Datatypes,
project_root => 'API,
schema_version => "1.0",
test_dir => "/topdir/t"});
#### this call will build everything - API,tests, helper modules
#### where name parameter is the name of your root element - "nsid:mymodel"
#
# it will create versioned API under /topdir/API/Datatypes/v1_0/nsid/ for nsid namespace prefix
# and /topdir/API/Datatypes/v1_0/nsid2/ for nsid2 namespace prefix
#
$api_builder->buildAPI('mymodel', $model);
#### this call will build only test suit
####
$api_builder->buildTests('mymodel', $model);
####
#### this call will build only Helper modules under /topdir/API/Datatypes/v1_0/ - namespace prefix mapping, basic element operations
####
$api_builder->buildHelpers();
####

creates new object, accepts reference to hash as parameters container where keys are:
current directoryPossible ways to call new():
### with defaults
$api_builder = XML::RelaxNG::Compact::PXB->new();
## passes hashref with explicit parameters, for the next example:
## api will be created at /root/XMLTypes/v1_0/
## and tests files under - /root/t
$api_builder = XML::RelaxNG::Compact::PXB->new({
top_dir => "/root/",
datatypes_root => "XMLTypes",
nsregistry => { 'nsid' => 'nsURI'},
project_root => 'API,
schema_version => "1.0",
test_dir => "t",
footer => POD::Credentials->new({author=> 'Joe Doe'}),
});
builds XML binding API recursively accepts parameters:
undef for the root elementreturns $self
shortcut to build Helper classes only, no arguments returns $self
prints accessors and mutators for the passed reference to array of names returns $self
shortcut to build test files only, no arguments returns $self
builds single class on the filesystem and corresponded test file accepts parameters:
returns $self
auxiliary method
it builds test file for current class
accepts:
reference to array with elements,
reference to array with attributes,
class name
name of the package
element name
returns: nothing
prints string into the file handler without new line
prints string into the file handler with new line added

Maxim Grigoriev (FNAL), maxim_at_fnal_dot_gov

You should have received a copy of the Fermitools license with this software. If not, see <http://fermitools.fnal.gov/about/terms.html>

Copyright(c) 2007-2008, Fermi Research Alliance (FRA)