XUpdate/LibXML.pm

filter: Statementstmt 8.4% 15 / 177 Branchbran 0.0% 0 / 104 Conditioncond 0.0% 0 / 21 MC/DCmcdc 0.0% 0 / 14 Subroutinesub 17.8% 5 / 28 Podpod 25.0% 5 / 20 totaltotal 6.8% 25 / 364 CC 76 SCAR 54.6
CC
76
Cov
5%
xupdate_command
650.0
process_instructions
342.0
process
72.0
CRAP 234.1
↑ Summary Normalize/LibXML.pm »
1 # $Id: LibXML.pm,v 1.15 2005/05/12 15:04:58 pajas Exp $
2  
3 package XML::XUpdate::LibXML;
4  
5 1 ▶use XML::LibXML;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use XML::LibXML::XPathContext;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use vars qw(@ISA $debug $VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 $debug=0;
12 1 $VERSION = '0.6.0';
13 }
14  
15 0 ▶sub strip_space {
Subroutine strip_space: not called CC=1 SCAR=6.9
Pod undocumented
16 0 my ($text)=@_;
17 0 $text=~s/^\s*//;
18 0 $text=~s/\s*$//;
19 0 return $text;
20 }
21  
22 0 ▶sub new {
Subroutine new: not called CC=2 SCAR=17.9
Pod documented
23 0 ▶ my $class=(ref($_[0]) || $_[0]);
Condition0%0/3
ref $_[0] || $_[0]
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $_[0] || $_[0]
ref $_[0] $_[0]
Truth table0%0/3
A || B
A= ref $_[0]B= $_[0]
ABresult
1X1
011
000
24 0 my $var_pool = {};
25 0 my $xpc = XML::LibXML::XPathContext->new();
26 0 $xpc->registerVarLookupFunc(\&_get_var,$var_pool);
27 0 return bless [$var_pool,
28 "http://www.xmldb.org/xupdate",
29 $xpc
30 ], $class;
31 }
32  
33 0 ▶sub registerNs {
Subroutine registerNs: not called CC=1 SCAR=6.9
Pod documented
34 0 my ($self,$prefix, $uri)=@_;
35 0 $self->[2]->registerNs($prefix,$uri);
36 }
37  
38 0 ▶sub init {
Subroutine init: not called CC=1 SCAR=6.9
Pod undocumented
39 0 my ($self,$doc)=@_;
40 0 $self->[2]->setContextNode($doc);
41 }
42  
43 0 ▶sub _context {
Subroutine _context: not called CC=1 SCAR=6.9
44 0 my ($self,$name,$value)=@_;
45 0 return $self->[2];
46 }
47  
48 0 ▶sub _set_var {
Subroutine _set_var: not called CC=2 SCAR=17.9
49 0 my ($self,$name,$value)=@_;
50 0 ▶ print STDERR "DEBUG: Storing $name as ",ref($value),"\n" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $XML::XUpdate::LibXML::debug 0 0 0
51 0 $self->[0]->{$name}=$value;
52 }
53  
54 0 ▶sub _get_var {
Subroutine _get_var: not called CC=1 SCAR=6.9
55 0 my ($data,$name)=@_;
56 0 return $data->{$name};
57 }
58  
59 0 ▶sub set_namespace {
Subroutine set_namespace: not called CC=1 SCAR=6.9
Pod documented
60 0 my ($self,$URI)=@_;
61 0 $self->[1]=$URI;
62 }
63  
64 0 ▶sub namespace {
Subroutine namespace: not called CC=1 SCAR=6.9
Pod documented
65 0 my ($self)=@_;
66 0 return $self->[1];
67 }
68  
69 0 ▶sub process {
Subroutine process: not called CC=8 SCAR=42.8
Pod documented
70 0 my ($self,$dom,$updoc)=@_;
71 0 ▶ return unless ref($self);
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self 0 0 0
72  
73 0 $self->init($dom);
74 0 ▶ print STDERR "DEBUG: Updating ",$dom->nodeName,"\n" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $XML::XUpdate::LibXML::debug 0 0 0
75 0 foreach my $command ($updoc->getDocumentElement()->childNodes()) {
76  
77 0 ▶ if ($command->nodeType == XML::LibXML::XML_ELEMENT_NODE) {
Branch: 1 branch
BranchTrueFalseTotal
if ($command->nodeType == 1) 0 0 0
78 0 ▶ if (lc($command->getNamespaceURI()) eq $self->namespace()) {
Branch: 1 branch
BranchTrueFalseTotal
if (lc $command->getNamespaceURI eq $self->namespace) { } 0 0 0
79 0 ▶ print STDERR "DEBUG: applying ",$command->toString(),"\n" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $XML::XUpdate::LibXML::debug 0 0 0
80 0 $self->xupdate_command($dom,$command);
81 } else {
82 0 ▶ print STDERR "DEBUG: Ignorint element ",$command->toString(),"\n" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $XML::XUpdate::LibXML::debug 0 0 0
83 }
84 }
85  
86 }
87 }
88  
89 0 ▶sub get_text {
Subroutine get_text: not called CC=4 SCAR=30.0
Pod undocumented
90 0 my ($self,$node)=@_;
91 0 my $text="";
92 0 foreach ($node->childNodes()) {
93 0 ▶ if ($_->nodeType() == XML::LibXML::XML_TEXT_NODE ||
Branch: 1 branch
BranchTrueFalseTotal
if ($_->nodeType == 3 or $_->nodeType == 4) 0 0 0
Condition0%0/3
$_->nodeType == 3 or $_->nodeType == 4
l!l&&r!l&&!r
000
MC/DC0%0/2
$_->nodeType == 3 or $_->nodeType == 4
$_->nodeType == 3 $_->nodeType == 4
Truth table0%0/3
A or B
A= $_->nodeType == 3B= $_->nodeType == 4
ABresult
1X1
011
000
94 $_->nodeType() == XML::LibXML::XML_CDATA_SECTION_NODE) {
95 0 $text.=$_->getData();
96 }
97 }
98 0 return strip_space($text);
99 }
100  
101 0 ▶sub add_attribute {
Subroutine add_attribute: not called CC=1 SCAR=6.9
Pod undocumented
102 0 my ($self, $node, $attr_node)=@_;
103 0 $node->setAttributeNS($attr_node->getNamespaceURI,
104 $attr_node->getName(),
105 $attr_node->getValue);
106 }
107  
108 0 ▶sub append {
Subroutine append: not called CC=3 SCAR=24.8
Pod undocumented
109 0 my ($self,$node,$results)=@_;
110 0 foreach (@$results) {
111 0 ▶ if ($_->nodeType == XML::LibXML::XML_ATTRIBUTE_NODE) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_->nodeType == 2) { } 0 0 0
112 0 $self->add_attribute($node,$_);
113 } else {
114 0 $node->appendChild($_);
115 }
116 }
117 }
118  
119 0 ▶sub insert_after {
Subroutine insert_after: not called CC=4 SCAR=30.0
Pod undocumented
120 0 my ($self,$node,$results)=@_;
121  
122 0 ▶ if ($node->nodeType == XML::LibXML::XML_ATTRIBUTE_NODE) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node->nodeType == 2) { } 0 0 0
123 0 $self->append($node->getOwnerElement(),$results);
124 } else {
125 0 foreach (reverse @$results) {
126 0 ▶ if ($_->nodeType == XML::LibXML::XML_ATTRIBUTE_NODE) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_->nodeType == 2) { } 0 0 0
127 0 $self->add_attribute($node->parentNode(),$_);
128 } else {
129 0 $node->parentNode()->insertAfter($_,$node);
130 }
131 }
132 }
133 }
134  
135 0 ▶sub insert_before {
Subroutine insert_before: not called CC=4 SCAR=30.0
Pod undocumented
136 0 my ($self,$node,$results)=@_;
137 0 ▶ if ($node->nodeType == XML::LibXML::XML_ATTRIBUTE_NODE) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node->nodeType == 2) { } 0 0 0
138 0 $self->append($node->getOwnerElement(),$results);
139 } else {
140 0 foreach (@$results) {
141 0 ▶ if ($_->nodeType == XML::LibXML::XML_ATTRIBUTE_NODE) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_->nodeType == 2) { } 0 0 0
142 0 $self->add_attribute($node->parentNode(),$_);
143 } else {
144 0 $node->parentNode()->insertBefore($_,$node);
145 }
146 }
147 }
148 }
149  
150 0 ▶sub append_child {
Subroutine append_child: not called CC=7 SCAR=40.3
Pod undocumented
151 0 my ($self,$node,$results,$child)=@_;
152 0 ▶ return unless @$results;
Branch: 1 branch
BranchTrueFalseTotal
unless @$results 0 0 0
153 0 ▶ if ($child ne "") {
Branch: 1 branch
BranchTrueFalseTotal
if ($child ne '') { } 0 0 0
154 # XUpdate WD is weird:
155 # child=1 should mean make the new node 1st child
156 # child=last() should mean make new node last child
157 # but if there are n children before insertion,
158 # last() evaluates to n but they want the new node
159 # to be (n+1)th.
160  
161 # so we must add it first, then calculate the position:
162 0 my $ctxt = $self->_context();
163 0 $self->append($node,$results);
164 0 my ($ref)=$ctxt->findnodes("node()[$child]",$node);
165 0 ▶ return unless $ref;
Branch: 1 branch
BranchTrueFalseTotal
unless $ref 0 0 0
166 # check whether we should move results before $ref node
167 0 foreach (@$results) {
168 0 ▶ return if $ref->isSameNode($_);
Branch: 1 branch
BranchTrueFalseTotal
if $ref->isSameNode($_) 0 0 0
169 }
170 # now move them
171 0 foreach (@$results) {
172 0 $_->unbindNode();
173 0 $node->insertBefore($_,$ref);
174 }
175 } else {
176 0 $self->append($node,$results);
177 }
178 }
179  
180 0 ▶sub update {
Subroutine update: not called CC=7 SCAR=40.3
Pod undocumented
181 0 my ($self,$node,$results)=@_;
182  
183 0 ▶ if ($node->nodeType == XML::LibXML::XML_TEXT_NODE ||
Branch: 3 branches
BranchTrueFalseTotal
if ($node->nodeType == 3 or $node->nodeType == 4) { } 0 0 0
elsif ($node->nodeType == 2 or $node->nodeType == 7) { } 0 0 0
elsif ($node->nodeType == 1) { } 0 0 0
Condition0%0/3
$node->nodeType == 3 or $node->nodeType == 4
l!l&&r!l&&!r
000
MC/DC0%0/2
$node->nodeType == 3 or $node->nodeType == 4
$node->nodeType == 3 $node->nodeType == 4
Truth table0%0/3
A or B
A= $node->nodeType == 3B= $node->nodeType == 4
ABresult
1X1
011
000
184 $node->nodeType == XML::LibXML::XML_CDATA_SECTION_NODE) {
185 0 $self->insert_after($node,$results);
186 0 $node->unbindNode();
187 ▶ } elsif ($node->nodeType == XML::LibXML::XML_ATTRIBUTE_NODE ||
Condition0%0/3
$node->nodeType == 2 or $node->nodeType == 7
l!l&&r!l&&!r
000
MC/DC0%0/2
$node->nodeType == 2 or $node->nodeType == 7
$node->nodeType == 2 $node->nodeType == 7
Truth table0%0/3
A or B
A= $node->nodeType == 2B= $node->nodeType == 7
ABresult
1X1
011
000
188 $node->nodeType == XML::LibXML::XML_PI_NODE) {
189 0 $node->setValue(strip_space(join "", map { $_->to_literal() } @$results));
190 } elsif ($node->nodeType == XML::LibXML::XML_ELEMENT_NODE) {
191 0 foreach ($node->childNodes()){
192 0 $_->unbindNode();
193 }
194 0 $self->append($node,$results);
195 }
196 }
197  
198 0 ▶sub remove {
Subroutine remove: not called CC=1 SCAR=6.9
Pod undocumented
199 0 my ($self, $node)=@_;
200 0 $node->unbindNode();
201 }
202  
203 0 ▶sub rename {
Subroutine rename: not called CC=1 SCAR=6.9
Pod undocumented
204 0 my ($self,$node,$name)=@_;
205 0 $node->setName($name);
206 }
207  
208 0 ▶sub process_instructions {
Subroutine process_instructions: not called CC=18 SCAR=58.3
Pod undocumented
209 0 my ($self, $dom, $command)=@_;
210  
211 0 my @result=();
212 0 foreach my $inst ($command->childNodes()) {
213 0 ▶ print STDERR "DEBUG: Instruction ",$command->toString(),"\n" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $XML::XUpdate::LibXML::debug 0 0 0
214 0 ▶ if ( $inst->nodeType == XML::LibXML::XML_ELEMENT_NODE ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($inst->nodeType == 1) { } 0 0 0
elsif ($inst->nodeType == 4 or $inst->nodeType == 3) { } 0 0 0
215 0 ▶ if ( $inst->getLocalName() eq 'element' ) {
Branch: 6 branches
BranchTrueFalseTotal
if ($inst->getLocalName eq 'element') { } 0 0 0
elsif ($inst->getLocalName eq 'attribute') { } 0 0 0
elsif ($inst->getLocalName eq 'text') { } 0 0 0
elsif ($inst->getLocalName eq 'processing-instruction') { } 0 0 0
elsif ($inst->getLocalName eq 'comment') { } 0 0 0
elsif ($inst->getLocalName eq 'value-of') { } 0 0 0
216 0 my $new;
217 0 ▶ if ($inst->hasAttribute('namespace') and
Branch: 1 branch
BranchTrueFalseTotal
if ($inst->hasAttribute('namespace') and $inst->getAttribute('name') =~ /:/) { } 0 0 0
Condition0%0/3
$inst->hasAttribute("namespace") and $inst->getAttribute("name") =~ /:/
!ll&&!rl&&r
000
MC/DC0%0/2
$inst->hasAttribute("namespace") and $inst->getAttribute("name") =~ /:/
$inst->hasAttribute("namespace") $inst->getAttribute("name") =~ /:/
Truth table0%0/3
A and B
A= $inst->hasAttribute("namespace")B= $inst->getAttribute("name") =~ /:/
ABresult
0X0
100
111
218 $inst->getAttribute('name')=~/:/) {
219 0 $new=$dom->getOwnerDocument()->createElementNS(
220 $inst->getAttribute('namespace'),
221 $inst->getAttribute('name')
222 );
223 } else {
224 0 $new=$dom->getOwnerDocument()->createElement($inst->getAttribute('name'));
225 }
226 0 $self->append($new,$self->process_instructions($dom,$inst));
227 0 push @result,$new;
228 } elsif ( $inst->getLocalName() eq 'attribute' ) {
229 0 ▶ if ($inst->hasAttribute('namespace') and
Branch: 1 branch
BranchTrueFalseTotal
if ($inst->hasAttribute('namespace') and $inst->getAttribute('name') =~ /:/) { } 0 0 0
Condition0%0/3
$inst->hasAttribute("namespace") and $inst->getAttribute("name") =~ /:/
!ll&&!rl&&r
000
MC/DC0%0/2
$inst->hasAttribute("namespace") and $inst->getAttribute("name") =~ /:/
$inst->hasAttribute("namespace") $inst->getAttribute("name") =~ /:/
Truth table0%0/3
A and B
A= $inst->hasAttribute("namespace")B= $inst->getAttribute("name") =~ /:/
ABresult
0X0
100
111
230 $inst->getAttribute('name')=~/:/) {
231 0 my $att=
232 $dom->getOwnerDocument()->
233 createAttributeNS(
234 $inst->getAttribute('namespace'),
235 $inst->getAttribute('name')
236 );
237 0 $att->setValue($self->get_text($inst));
238 0 push @result,$att;
239 } else {
240 0 my $att=
241 $dom->getOwnerDocument()->
242 createAttribute(
243 $inst->getAttribute('name')
244 );
245 0 $att->setValue($self->get_text($inst));
246 0 push @result,$att;
247 }
248 } elsif ( $inst->getLocalName() eq 'text' ) {
249 0 push @result,$dom->getOwnerDocument()->createTextNode($self->get_text($inst));
250 } elsif ( $inst->getLocalName() eq 'processing-instruction' ) {
251 0 push @result,$dom->getOwnerDocument()->createProcessingInstruction(
252 $inst->getAttribute('name'),
253 $self->get_text($inst)
254 );
255 } elsif ( $inst->getLocalName() eq 'comment' ) {
256 0 push @result,$dom->getOwnerDocument()->createComment($self->get_text($inst));
257 } elsif ( $inst->getLocalName() eq 'value-of' ) {
258 0 my $value=$self->get_select($dom,$inst);
259 0 ▶ if ($value->isa('XML::LibXML::NodeList')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value->isa('XML::LibXML::NodeList')) { } 0 0 0
260 0 push @result, map { $_->cloneNode(1) }$value->get_nodelist;
261 } else {
262 0 push @result,$dom->getOwnerDocument()->createTextNode($value->to_literal());
263 }
264 } else {
265 # not in XUpdate DTD but in examples of XUpdate WD
266 0 ▶ push @result,$dom->getOwnerDocument()->importNode($inst)
Branch: 1 branch
BranchTrueFalseTotal
unless lc $inst->getNamespaceURI eq $self->namespace 0 0 0
267 unless (lc($inst->getNamespaceURI) eq $self->namespace());
268 }
269 ▶ } elsif ( $inst->nodeType == XML::LibXML::XML_CDATA_SECTION_NODE ||
Condition0%0/3
$inst->nodeType == 4 or $inst->nodeType == 3
l!l&&r!l&&!r
000
MC/DC0%0/2
$inst->nodeType == 4 or $inst->nodeType == 3
$inst->nodeType == 4 $inst->nodeType == 3
Truth table0%0/3
A or B
A= $inst->nodeType == 4B= $inst->nodeType == 3
ABresult
1X1
011
000
270 $inst->nodeType == XML::LibXML::XML_TEXT_NODE) {
271 0 push @result,$dom->getOwnerDocument()->importNode($inst);
272 }
273 }
274 0 return \@result;
275 }
276  
277 0 ▶sub get_select {
Subroutine get_select: not called CC=2 SCAR=17.9
Pod undocumented
278 0 my ($self,$dom,$node)=@_;
279 0 my $xpath=$node->getAttribute('select');
280 0 ▶ if ($xpath eq "") {
Branch: 1 branch
BranchTrueFalseTotal
if ($xpath eq "") 0 0 0
281 0 die "Error: Required attribute select is missing or empty at:\n".
282 $node->toString()."\nAborting!\n";
283 }
284 0 return $self->_context->find($xpath);
285 }
286  
287 0 ▶sub get_test {
Subroutine get_test: not called CC=2 SCAR=17.9
Pod undocumented
288 0 my ($self,$dom,$node)=@_;
289 0 my $xpath=$node->getAttribute('test');
290 0 ▶ if ($xpath eq "") {
Branch: 1 branch
BranchTrueFalseTotal
if ($xpath eq "") 0 0 0
291 0 die "Error: Required attribute test is missing or empty at:\n".
292 $node->toString()."\nAborting!\n";
293 }
294 0 return $self->_context->find($xpath);
295 }
296  
297 0 ▶sub xupdate_command {
Subroutine xupdate_command: not called CC=25 SCAR=64.8
Pod undocumented
298 0 my ($self,$dom,$command)=@_;
299 0 ▶ return unless ($command->getType == XML::LibXML::XML_ELEMENT_NODE);
Branch: 1 branch
BranchTrueFalseTotal
unless $command->getType == 1 0 0 0
300 0 ▶ if ($command->getLocalName() eq 'variable') {
Branch: 2 branches
BranchTrueFalseTotal
if ($command->getLocalName eq 'variable') { } 0 0 0
elsif ($command->getLocalName eq 'if') { } 0 0 0
301 0 my $select=$self->get_select($dom,$command);
302 0 $self->_set_var($command->getAttribute('name'), $select);
303 } elsif ($command->getLocalName() eq 'if') {
304 # xu:if
305 0 my $test=$self->get_test($dom,$command);
306 0 ▶ if ($test) {
Branch: 1 branch
BranchTrueFalseTotal
if ($test) 0 0 0
307 0 ▶ print STDERR "DEBUG: Conditional execution of ",$dom->nodeName,"\n" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $XML::XUpdate::LibXML::debug 0 0 0
308 0 foreach my $subcommand ($command->childNodes()) {
309
310 0 ▶ if ($subcommand->nodeType == XML::LibXML::XML_ELEMENT_NODE) {
Branch: 1 branch
BranchTrueFalseTotal
if ($subcommand->nodeType == 1) 0 0 0
311 0 ▶ if (lc($subcommand->getNamespaceURI()) eq $self->namespace()) {
Branch: 1 branch
BranchTrueFalseTotal
if (lc $subcommand->getNamespaceURI eq $self->namespace) { } 0 0 0
312 0 ▶ print STDERR "DEBUG: Applying ",$subcommand->toString(),"\n" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $XML::XUpdate::LibXML::debug 0 0 0
313 0 $self->xupdate_command($dom,$subcommand);
314 } else {
315 0 ▶ print STDERR "DEBUG: Ignoring element ",$subcommand->toString(),"\n" if $debug;
Branch: 1 branch
BranchTrueFalseTotal
if $XML::XUpdate::LibXML::debug 0 0 0
316 }
317 }
318
319 }
320 }
321 } else {
322 0 my $select=$self->get_select($dom,$command);
323 0 ▶ if ($select->isa('XML::LibXML::NodeList')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($select->isa('XML::LibXML::NodeList')) { } 0 0 0
324 0 my @refnodes=$select->get_nodelist();
325 0 ▶ if (@refnodes) {
Branch: 1 branch
BranchTrueFalseTotal
if (@refnodes) 0 0 0
326
327 # xu:insert-after
328 0 ▶ if ($command->getLocalName eq 'insert-after') {
Branch: 6 branches
BranchTrueFalseTotal
if ($command->getLocalName eq 'insert-after') { } 0 0 0
elsif ($command->getLocalName eq 'insert-before') { } 0 0 0
elsif ($command->getLocalName eq 'append') { } 0 0 0
elsif ($command->getLocalName eq 'update') { } 0 0 0
elsif ($command->getLocalName eq 'remove') { } 0 0 0
elsif ($command->getLocalName eq 'rename') { } 0 0 0
329  
330 0 foreach (@refnodes) {
331 0 $self->insert_after($_,
332 $self->process_instructions($dom,$command));
333 }
334  
335 # xu:insert-before
336 } elsif ($command->getLocalName eq 'insert-before') {
337  
338 0 foreach (@refnodes) {
339 0 $self->insert_before($_,
340 $self->process_instructions($dom,$command));
341 }
342  
343 # xu:append
344 } elsif ($command->getLocalName eq 'append') {
345  
346 0 foreach (@refnodes) {
347 0 my $results=$self->process_instructions($dom,$command);
348 0 my $child=$command->getAttribute('child');
349 0 $self->append_child($_,$results,$child);
350 }
351  
352 # xu:update
353 } elsif ($command->getLocalName eq 'update') {
354  
355 0 foreach (@refnodes) {
356 0 my $results=$self->process_instructions($dom,$command);
357 # Well, XUpdate WD is not very specific about this.
358 # The content of this element should be PCDATA only.
359 # I'm extending WD by allowing instruction list.
360 0 $self->update($_,$results);
361 }
362  
363 # xu:remove
364 } elsif ($command->getLocalName eq 'remove') {
365  
366 0 foreach (@refnodes) {
367 0 $self->remove($_);
368 }
369  
370 # xu:rename
371 } elsif ($command->getLocalName eq 'rename') {
372  
373 0 foreach (@refnodes) {
374 0 $self->rename($_,$self->get_text($command));
375 }
376  
377 }
378 }
379 } else {
380 0 die "XPath does not lead to a nodelist: ",$command->getAttribute('select'),"\n";
381 }
382 }
383 }
384  
385 1 1;
386  
387 __END__
↑ Summary Normalize/LibXML.pm »