NAME
PRANG::Graph::Meta::Attr - metaclass metarole for XML attributes
SYNOPSIS
package My::XML::Language::Node;
use Moose;
use PRANG::Graph;
has_attr 'someattr' =>
is => "rw",
isa => $str_subtype,
predicate => "has_someattr",
;
DESCRIPTION
When defining a class, you mark attributes which correspond to XML attributes. To do this in a way that the PRANG marshalling machinery can use when converting to XML and back, make the attributes have this metaclass.
You could do this in principle with:
has 'someattr' =>
traits => ['PRANG::Attr'],
...
But PRANG::Graph exports a convenient shorthand for you to use.
If you like, you can also set the xmlns
and xml_name
attribute property, to override the default behaviour, which is to assume that the XML attribute name matches the Moose attribute name, and that the XML namespace of the attribute matches that of the class in which it is defined.
If you set the xml_required
property, then it is an error for the property not to be set when parsing or emitting.
SEE ALSO
PRANG::Graph::Meta::Class, PRANG::Graph::Meta::Element
AUTHOR AND LICENCE
Development commissioned by NZ Registry Services, and carried out by Catalyst IT - http://www.catalyst.net.nz/
Copyright 2009, 2010, NZ Registry Services. This module is licensed under the Artistic License v2.0, which permits relicensing under other Free Software licenses.