Robin Smidsrød > XML-Rabbit-0.2.1 > XML::Rabbit::Trait::XPathObjectMap

Download:
XML-Rabbit-0.2.1.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  0
View/Report Bugs
Module Version: 0.2.1   Source   Latest Release: XML-Rabbit-0.4.0

NAME ^

XML::Rabbit::Trait::XPathObjectMap - Multiple XML DOM object xpath extractor trait

VERSION ^

version 0.2.1

SYNOPSIS ^

    package MyXMLSyntaxNode;
    use Moose;
    with 'XML::Rabbit::Node';

    has 'persons' => (
        isa         => 'HashRef[MyXMLSyntax::Person]',
        traits      => [qw(XPathObjectMap)],
        xpath_query => './persons/*',
        xpath_key   => './@name',
    );

    no Moose;
    __PACKAGE__->meta->make_immutable();

    1;

DESCRIPTION ^

This module provides the extraction of multiple complex values (subtrees) from an XML node based on an XPath query. Each subtree is used as input for the constructor of the class specified in the isa attribute. All of the extracted objects are then put into an arrayref which is accessible via the parent attribute.

See XML::Rabbit for a more complete example.

ATTRIBUTES ^

isa_map

Specifies the prefix:tag to class name mapping used with union xpath queries. See XML::Rabbit for more detailed information.

xpath_key

The xpath query that specifies what will be put in the key in the hash. Required.

METHODS ^

_build_default

Returns a coderef that is run to build the default value of the parent attribute. Read Only.

AUTHOR ^

Robin Smidsrød <robin@smidsrod.no>

COPYRIGHT AND LICENSE ^

This software is copyright (c) 2012 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.

syntax highlighting: