XML::Rabbit::Sugar(3)

NAME
XML::Rabbit::Sugar - Sugar functions for easier declaration of xpath attributes

VERSION
version 0.4.1

FUNCTIONS

  add_xpath_namespace($namespace, $url)
Adds the XPath namespace with its associated url to the namespace_map hash.

  has_xpath_value($attr_name, $xpath_query, @moose_params)
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".

    has_xpath_value 'name' => './name',
        ...
    ;

  has_xpath_value_list($attr_name, $xpath_query, @moose_params)
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".

    has_xpath_value_list 'streets' => './street',
        ...
    ;

  has_xpath_value_map($attr_name, $xpath_query, $xpath_key, $xpath_value, @moose_params)
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.

    has_xpath_value_map 'employee_map' => './employees/*',
        './@ssn' => './name',
        ...
    ;

  has_xpath_object($attr_name, $xpath_query, $isa, @moose_params)
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".

    has_xpath_object 'department' => './department' => 'My::Department';

  has_xpath_object($attr_name, $xpath_query, $isa_map, @moose_params)
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".

    has_xpath_object 'department' => './department|./team' =>
        {
            'department' => 'My::Department',
            'team'       => 'My::Team',
        },
        ...
    ;

  has_xpath_object_list($attr_name, $xpath_query, $isa, @moose_params)
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".

    has_xpath_object_list 'customers' => './customer' => 'My::Customer';

  has_xpath_object_list($attr_name, $xpath_query, $isa_map, @moose_params)
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".

    has_xpath_object_list 'externals' => './customer|./partner' =>
        {
            'customer' => 'My::Customer',
            'partner'  => 'My::Partner',
        },
        ...
    ;

  has_xpath_object_map($attr_name, $xpath_query, $xpath_key, $isa, @moose_params)
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.

    has_xpath_object_map 'product_map' => './products/*',
        './@code' => 'My::Product',
        ...
    ;

  has_xpath_object_map($attr_name, $xpath_query, $xpath_key, $isa_map, @moose_params)
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.

    has_xpath_object_map 'merchandise_map' => './products/*|./services/*',
        './@code' => {
                        'service' => 'My::Service',
                        'product' => 'My::Product',
                     },
        ...
    ;

  finalize_class()
Convenience function that calls __PACKAGE__->meta->make_immutable() for you. Always returns true value.

AUTHOR
Robin Smidsrød <robin@smidsrod.no>

COPYRIGHT AND LICENSE
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.