XML::Rabbit::Sugar - Sugar functions for easier declaration of xpath attributes
version 0.4.1
Adds the XPath namespace with its associated url to the namespace_map hash.
Extracts a single string according to the xpath query specified. The attribute isa parameter is automatically set to Str. The attribute native trait is automatically set to String.
Str
String
has_xpath_value 'name' => './name', ... ;
Extracts an array of strings according to the xpath query specified. The attribute isa parameter is automatically set to ArrayRef[Str]. The attribute native trait is automatically set to Array.
ArrayRef[Str]
Array
has_xpath_value_list 'streets' => './street', ... ;
Extracts a hash of strings according to the xpath query specified. The attribute isa parameter is automatically set to HashRef[Str]. The attribute native trait is automatically set to Hash. The xpath query should represent the multiple elements you want to retrieve. The xpath_key and xpath_value queries must specify how to lookup the key and value for each hash entry. Most likely you'd want to use relative queries for the key and value like the example below shows.
HashRef[Str]
Hash
has_xpath_value_map 'employee_map' => './employees/*', './@ssn' => './name', ... ;
Extracts a single object according to the xpath query specified. The attribute isa parameter is automatically set to the specified class name. In the example below it would be set to My::Department.
My::Department
has_xpath_object 'department' => './department' => 'My::Department';
Extracts a single object according to the xpath query specified. The attribute isa parameter is automatically set to a union of the values in the specified hash. In the example below it would be set to My::Department|My::Team.
My::Department|My::Team
has_xpath_object 'department' => './department|./team' => { 'department' => 'My::Department', 'team' => 'My::Team', }, ... ;
Extracts an array of objects according to the xpath query specified. The attribute isa parameter is automatically set to ArrayRef[My::Customer] (in example below). The attribute native trait is automatically set to Array.
ArrayRef[My::Customer]
has_xpath_object_list 'customers' => './customer' => 'My::Customer';
Extracts an array of objects according to the xpath query specified. The attribute isa parameter is automatically set to ArrayRef[My::Customer|My::Partner] (in example below). The attribute native trait is automatically set to Array.
ArrayRef[My::Customer|My::Partner]
has_xpath_object_list 'externals' => './customer|./partner' => { 'customer' => 'My::Customer', 'partner' => 'My::Partner', }, ... ;
Extracts a hash of objects according to the xpath query specified. The attribute isa parameter is automatically set to HashRef[My::Product] (see example). The attribute native trait is automatically set to Hash. The xpath query should represent the multiple elements you want to retrieve. The xpath_key query must specify how to lookup the key for each hash entry. Most likely you'd want to use relative queries for the key like the example below shows.
HashRef[My::Product]
has_xpath_object_map 'product_map' => './products/*', './@code' => 'My::Product', ... ;
Extracts a hash of objects according to the xpath query specified. The attribute isa parameter is automatically set to HashRef[My::Product|My::Service] (see example). The attribute native trait is automatically set to Hash. The xpath query should represent the multiple elements you want to retrieve. The xpath_key query must specify how to lookup the key for each hash entry. Most likely you'd want to use relative queries for the key like the example below shows.
HashRef[My::Product|My::Service]
has_xpath_object_map 'merchandise_map' => './products/*|./services/*', './@code' => { 'service' => 'My::Service', 'product' => 'My::Product', }, ... ;
Convenience function that calls __PACKAGE__->meta->make_immutable() for you. Always returns true value.
Robin Smidsrød <robin@smidsrod.no>
This software is copyright (c) 2015 by Robin Smidsrød.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install XML::Rabbit, copy and paste the appropriate command in to your terminal.
cpanm
cpanm XML::Rabbit
CPAN shell
perl -MCPAN -e shell install XML::Rabbit
For more information on module installation, please visit the detailed CPAN module installation guide.