package XML::RelaxNG::Compact::PXB; use strict; use warnings; use English qw( -no_match_vars); use version; our $VERSION = '0.10'; =head1 NAME XML::RelaxNG::Compact::PXB - create perl XML (RelaxNG Compact) data binding API =head1 VERSION Version 0.10 =head1 DESCRIPTION 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 L test will be performed as part of the tests suit. See L for more details and examples. =head1 SYNOPSIS ### 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(); #### =head1 METHODS =cut use IO::File; use File::Path; use Data::Dumper; use FindBin; use Carp; use POD::Credentials; use Class::Accessor::Fast; use Class::Fields; use base qw(Class::Accessor::Fast Class::Fields); use fields qw(debug top_dir datatypes_root project_root schema_version test_dir footer nsregistry _schema_version_dir _TESTS _fh _fhtest _path _root _known_class _existed DEBUG); XML::RelaxNG::Compact::PXB->mk_accessors(XML::RelaxNG::Compact::PXB->show_fields('Public'),'_fh', '_fhtest', '_TESTS'); =head2 new({}) creates new object, accepts reference to hash as parameters container where keys are: =over =item B - set it to something defined to provide extra logging =item B - full pathname to the api root dir, for example test files will be placed as top_dir/test_dir B C =item B - reference to the hash with {ns_prefix => ns_URI} pairs, it will be built into the Element class B just XSD and XSI namespaces =item B - name of the generated datatypes directory B I =item B - name of the API project directory, all packages will have naming beginning with this one B I, with B default value every package will have API::XMLTYpes:: pre-fix =item B - version identifier for your XML schema B I<1.0> =item B - name for the test suit files ( relative to the ) B I =item B