PRANG

XML to Moose objects and back!
Download

PRANG Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Sam Crawley
  • Publisher web site:
  • http://search.cpan.org/~mutant/

PRANG Tags


PRANG Description

PRANG is an XML Graph engine, which provides post-schema validation objects (PSVO).It is designed for implementing XML languages for which a description of the valid sets of XML documents is available - for example, a DTD, W3C XML Schema or Relax specification. With PRANG (and, like XML::Toolkit), your class structure is your XML Graph.XML namespaces are supported, and the module tries to make many XML conventions as convenient as possible in the generated classes. This includes XML data (elements with no attributes and textnode contents), and presence elements (empty elements with no attributes which indicate something). It also supports mixed and unprocessed portions of the XML, and "pluggable" specifications.Currently, these must be manually constructed as in the example - details on this are to be found on the PRANG::Graph::Meta::Element and PRANG::Graph::Meta::Attr perldoc. There is also a cookbook of examples - see PRANG::Cookbook.However, eventually it should be possible to automatically process schema documents to produce a class structure (see "KNOWN LIMITATIONS").SYNOPSIS # step 1. define a common role for nodes in your XML language package XML::Language::Node; use Moose::Role; sub xmlns { "http://example.com/language/1.0" } # step 2. define the root node(s) of your language package XML::Language; use Moose; use PRANG::Graph; sub root_element { "envy" }; has_attr 'laziness' => is => "ro", isa => "Str", ; has_element 'lust' => is => "ro", isa => "XML::Language::Lust", ; with 'PRANG::Graph', 'XML::Language::Node'; # step 3. define further elements in your schema package XML::Language::Lust; use Moose; use PRANG::Graph; use PRANG::XMLSchema::Types; has_attr 'gluttony' => is => "ro", isa => "PRANG::XMLSchema::byte", ; has_element 'sins' => is => "ro", isa => "ArrayRef", xml_nodeName => { 'lust' => 'XML::Language::Lust', 'anger' => 'Str', }, ; has_element 'greed' => is => "ro", isa => "Bool", ; with 'XML::Language::Node'; # step 4a. parse! my $object = XML::Language->parse( < anger >You wouldn't like me when I'm angry< /anger > < lust > < anger >You've done it now! < greed / > < /lust > < /lust > < /envy > XML; # Parsing the above would give you the same structure as this: XML::Language->new( laziness => "Very", lust => XML::Language::Lust->new( gluttony => 127, sins => , greed => 1, ), ], ); # step 4b. emit! $format = 1; print $object->to_xml($format);Product's homepage


PRANG Related Software