File Coverage

blib/lib/PRANG/Graph/Node.pm
Criterion Covered Total %
statement 3 9 33.3
branch 0 2 0.0
condition n/a
subroutine 1 3 33.3
pod 0 2 0.0
total 4 16 25.0


line stmt bran cond sub pod time code
1              
2             package PRANG::Graph::Node;
3             $PRANG::Graph::Node::VERSION = '0.19';
4 7     7   1511 use Moose::Role;
  7         14  
  7         53  
5              
6 0     0 0   sub accept_many {0}
7              
8             #method accept( XML::LibXML::Node $node, PRANG::Graph::Context $ctx )
9             # returns ($key, $value, $nodeNameIfAmbiguous)
10             requires 'accept';
11              
12             #method complete( PRANG::Graph::Context $ctx )
13             # returns Bool
14             requires 'complete';
15              
16             #method expected( PRANG::Graph::Context $ctx )
17             # returns (@Str)
18             requires 'expected';
19              
20             # method output ( Object $item, XML::LibXML::Element $node, HashRef $xsi )
21             requires 'output';
22              
23             sub createTextNode {
24 0     0 0   my $self = shift;
25 0           my $doc = shift;
26 0           my $text = shift;
27            
28 0 0         my $method = $PRANG::EMIT_CDATA ? 'createCDATASection' : 'createTextNode';
29            
30 0           my $tn = $doc->$method($text);
31             }
32              
33             1;
34              
35             __END__
36              
37             =head1 NAME
38              
39             PRANG::Graph::Node - role for nodes in XML Graph machinery
40              
41             =head1 SYNOPSIS
42              
43             package PRANG::Graph::Foo;
44             with 'PRANG::Graph::Node';
45              
46             =head1 DESCRIPTION
47              
48             This role is essentially an interface which different types of
49             acceptors/emitted in the marshalling machinery must implement.
50              
51             You should hopefully not have to implement or poke into this class,
52             but if you do end up there while debugging then this documentation is
53             for you.
54              
55             =head1 REQUIRED METHODS
56              
57             Currently there are four methods required;
58              
59             =head2 B<accept( XML::LibXML::Node $node, PRANG::Graph::Context $ctx ) returns ($key, $value, $nodeNameIfAmbiguous)>
60              
61             Given an XML node, completely and recursively parse that node,
62             construct an object and return that object along with the name of the
63             node if the schema requires it.
64              
65             Updates C<$ctx> with any parse state affected by the operation.
66              
67             =head2 B<complete( PRANG::Graph::Context $ctx ) returns Bool>
68              
69             Returns true if the acceptor could be happy with the amount of parsing
70             that has been recorded in C<$ctx> or not.
71              
72             =head2 B<expected( PRANG::Graph::Context $ctx ) returns (@Str)>
73              
74             If there has not been enough accepted, then this function returns
75             something useful for building a helpful exception message.
76              
77             =head2 B<output( Object $item, XML::LibXML::Element $node, HashRef $xsi)>
78              
79             Given the item C<$item>, marshall to XML by constructing new LibXML nodes and attaching to C<$node>; C<$xsi> is the current XML namespaces mapping.
80              
81             =head1 SEE ALSO
82              
83             L<PRANG::Graph::Meta::Class>, L<PRANG::Graph::Meta::Attr>,
84             L<PRANG::Graph::Meta::Element>, L<PRANG::Marshaller>,
85             L<PRANG::Graph::Context>
86              
87             Implementations:
88              
89             L<PRANG::Graph::Seq>, L<PRANG::Graph::Quant>, L<PRANG::Graph::Choice>,
90             L<PRANG::Graph::Element>, L<PRANG::Graph::Text>
91              
92             =head1 AUTHOR AND LICENCE
93              
94             Development commissioned by NZ Registry Services, and carried out by
95             Catalyst IT - L<http://www.catalyst.net.nz/>
96              
97             Copyright 2009, 2010, NZ Registry Services. This module is licensed
98             under the Artistic License v2.0, which permits relicensing under other
99             Free Software licenses.
100              
101             =cut
102