File: Iterator.pod

package info (click to toggle)
libxml-compile-perl 1.64-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,304 kB
  • sloc: perl: 11,616; makefile: 7
file content (145 lines) | stat: -rw-r--r-- 3,837 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
=encoding utf8

=head1 NAME

XML::Compile::Iterator - reduce view on a node tree

=head1 SYNOPSIS

=head1 DESCRIPTION

It would have been nice to be able to use XML::LibXML::Iterator, but
on the moment of this writing, that module is not maintained.  Besides,
this implementation of the iterator is more specific for our purpose.
The main user for this object currently is L<XML::Compile::Translate|XML::Compile::Translate>.

=head1 METHODS

=head2 Constructors

=over 4

=item $obj-E<gt>B<descend>( [$node, [$path, [$filter]]] )

The $node is a child of the node handled by the iterator where this
method is called upon.  Without explicit $node, the current node is used.
Returned is a new L<XML::Compile::Iterator|XML::Compile::Iterator> object.  The new iterator
will use the same $filter as the parent iterator by default.  The internal
administered path with be extended with the $path.

=item XML::Compile::Iterator-E<gt>B<new>($node, $path, $filter,)

The $node is a XML::LibXML::Node object, of which the direct children
are inspected.

The $filter a CODE reference which is called for each child node.
The only parameter is the parent $node, and then it must return
either true or false.  In case of true, the node is selected.
The FILTERS is applied to all children of the $node once, when the
first child is requested by the program.

=back

=head2 Attributes

=over 4

=item $obj-E<gt>B<filter>()

Returns the CODE reference which is used to select the nodes.

=item $obj-E<gt>B<node>()

Returns the XML::LibXML::Node node of which the children are walked
through.

=item $obj-E<gt>B<path>()

The path represents the location where the node is, like a symbolic
link, how you got there.

=back

=head2 Scanning

=over 4

=item $obj-E<gt>B<childs>()

Returns the child nodes which fulfil the filter requirements.  In LIST
context as list, in SCALAR context as reference to an ARRAY.

=item $obj-E<gt>B<currentChild>()

Returns the current child node.

=item $obj-E<gt>B<firstChild>()

Returns the first child node.  Does not change the current position.

=item $obj-E<gt>B<lastChild>()

Returns the last child node which fulfills the requirements.
Does not change the current position.

=item $obj-E<gt>B<nextChild>()

Returns the next child when available, otherwise C<undef>.

=item $obj-E<gt>B<nrChildren>()

Returns the number of childnodes which fulfill the restriction.

=item $obj-E<gt>B<previousChild>()

Returns the previous child when available, otherwise C<undef>.

=back

=head2 simplify XML node access

=over 4

=item $obj-E<gt>B<currentContent>()

Returns the textContent of the L<currentChild()|XML::Compile::Iterator/"Scanning"> node, or undef.

=item $obj-E<gt>B<currentLocal>()

Returns the local name of the L<currentChild()|XML::Compile::Iterator/"Scanning">, or the empty string.

=item $obj-E<gt>B<currentType>()

Returns the type of the L<currentChild()|XML::Compile::Iterator/"Scanning">, or the empty string.

=item $obj-E<gt>B<nodeLocal>()

Returns the local name of the L<node()|XML::Compile::Iterator/"Attributes">, or the empty string.

=item $obj-E<gt>B<nodeNil>()

Returns true if the current node has C<xsi:type="true">.

=item $obj-E<gt>B<nodeType>()

Returns the type of the L<node()|XML::Compile::Iterator/"Attributes">, or the empty string.

=item $obj-E<gt>B<textContent>()

Returns the textContent of the L<node()|XML::Compile::Iterator/"Attributes">, or undef.

=back

=head1 SEE ALSO

This module is part of XML-Compile distribution version 1.64,
built on October 21, 2024. Website: F<http://perl.overmeer.net/xml-compile/>

=head1 LICENSE

Copyrights 2006-2024 by [Mark Overmeer <markov@cpan.org>]. For other contributors see ChangeLog.

This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
See F<http://dev.perl.org/licenses/>