| 63 |
return $new_child; |
return $new_child; |
| 64 |
} # insert_before |
} # insert_before |
| 65 |
|
|
| 66 |
|
## NOTE: Only applied to Elements and Documents |
| 67 |
sub remove_child ($$) { |
sub remove_child ($$) { |
| 68 |
my ($self, $old_child) = @_; |
my ($self, $old_child) = @_; |
| 69 |
my $parent_list = $self->{child_nodes}; |
my $parent_list = $self->{child_nodes}; |
| 81 |
return @{shift->{child_nodes}} > 0; |
return @{shift->{child_nodes}} > 0; |
| 82 |
} # has_child_nodes |
} # has_child_nodes |
| 83 |
|
|
| 84 |
|
## NOTE: Only applied to Elements and Documents |
| 85 |
|
sub last_child ($) { |
| 86 |
|
my $self = shift; |
| 87 |
|
return @{$self->{child_nodes}} ? $self->{child_nodes}->[-1] : undef; |
| 88 |
|
} # last_child |
| 89 |
|
|
| 90 |
|
## NOTE: Only applied to Elements and Documents |
| 91 |
|
sub previous_sibling ($) { |
| 92 |
|
my $self = shift; |
| 93 |
|
my $parent = $self->{parent_node}; |
| 94 |
|
return undef unless defined $parent; |
| 95 |
|
my $r; |
| 96 |
|
for (@{$parent->{child_nodes}}) { |
| 97 |
|
if ($_ eq $self) { |
| 98 |
|
return $r; |
| 99 |
|
} else { |
| 100 |
|
$r = $_; |
| 101 |
|
} |
| 102 |
|
} |
| 103 |
|
return undef; |
| 104 |
|
} # previous_sibling |
| 105 |
|
|
| 106 |
sub ELEMENT_NODE () { 1 } |
sub ELEMENT_NODE () { 1 } |
| 107 |
sub ATTRIBUTE_NODE () { 2 } |
sub ATTRIBUTE_NODE () { 2 } |
| 108 |
sub TEXT_NODE () { 3 } |
sub TEXT_NODE () { 3 } |
| 189 |
}, ref $self; |
}, ref $self; |
| 190 |
for my $ns (keys %{$self->{attributes}}) { |
for my $ns (keys %{$self->{attributes}}) { |
| 191 |
for my $ln (keys %{$self->{attributes}->{$ns}}) { |
for my $ln (keys %{$self->{attributes}->{$ns}}) { |
| 192 |
|
my $attr = $self->{attributes}->{$ns}->{$ln}; |
| 193 |
$clone->{attributes}->{$ns}->{$ln} = bless { |
$clone->{attributes}->{$ns}->{$ln} = bless { |
| 194 |
prefix => $self->{attributes}->{$ns}->{$ln}->{prefix}, |
namespace_uri => $attr->{namespace_uri}, |
| 195 |
value => $self->{attributes}->{$ns}->{$ln}->{value}, |
prefix => $attr->{prefix}, |
| 196 |
|
local_name => $attr->{local_name}, |
| 197 |
|
value => $attr->{value}, |
| 198 |
}, ref $self->{attributes}->{$ns}->{$ln}; |
}, ref $self->{attributes}->{$ns}->{$ln}; |
| 199 |
} |
} |
| 200 |
} |
} |