Maxim Grigoriev > XML-RelaxNG-Compact-PXB-0.15.5 > XML::RelaxNG::Compact::PXB

Download:
XML-RelaxNG-Compact-PXB-0.15.5.tgz

Dependencies

Annotate this POD

CPAN RT

New  1
Open  0
View/Report Bugs
Module Version: 0.15   Source  

NAME ^

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

VERSION ^

Version 0.15

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 Perl::Critic test will be performed as part of the tests suit.

See XML::RelaxNG::Compact::DataModel for more details and examples.

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        =>   "t",
                                            footer => POD::Credentials->new({author=> 'Author Name', 
                                                                                license=> ' This stuff is for free !',
                                                                                copyright => 'Copyright (c) 2011, by me'});

      #### 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({name => 'mymodel', element => $model});
      
     
      #### this call will build only test suit
      ####
      $api_builder->buildTests({name => 'mymodel', element => $model});

      ####

      #### this call will build only Helper modules under /topdir/API/Datatypes/v1_0/ -  
      #### namespace prefix mapping, basic element operations
      ####
      
      $api_builder->buildHelpers();

      ####

METHODS ^

new({})

creates new object, accepts reference to hash as parameters container where keys are:

Possible 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'}),
                                            });

buildAPI()

builds XML binding API recursively accepts hashref with keys:

returns $self

buildHelpers

  shortcut to build Helper classes only, no arguments
  returns $self

buildAM

 prints accessors and mutators for the passed reference to array of names
 returns $self

buildTests

 shortcut to build test files  only, no arguments
 returns $self

buildClass

builds single class on the filesystem and corresponded test file accepts position bounded parameters:

returns $self

buildTest

 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

saying

 prints string into the  file handler without new line

sayIt

 prints string into the   file handler with new line added

AUTHOR ^

Maxim Grigoriev (FNAL), maxim_at_fnal_dot_gov

LICENSE ^

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

COPYRIGHT ^

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

syntax highlighting: