if (!defined($nsup)) {
$nsup = XML::NamespaceSupport->new;
}
- $nsup->push_context;
-
- # see if this node contains any namespace declarations that are relevant
- # for us
- my $attrs = $node->getAttributes;
- if (defined($attrs)) {
- for my $attr ($attrs->getValues) {
- my $name = $attr->getName;
- if ($name =~ /^xmlns:(.*)$/) {
- $nsup->declare_prefix($1, $attr->getValue);
- $node->removeAttribute($name) if ($clean);
- }
- }
- }
-
+
if (!ref($obj)) { # overwrite
for my $child ($node->getChildNodes) {
$node->removeChild($child);
} elsif (ref($obj) eq 'HASH') { # substitute
for my $child ($node->getChildNodes) {
my $processed = 0;
+ $nsup->push_context;
if ($child->getNodeType == XML::DOM::ELEMENT_NODE) {
+ # see if this node contains any namespace declarations that are relevant
+ # for us
+ my $attrs = $child->getAttributes;
+ if (defined($attrs)) {
+ for my $attr ($attrs->getValues) {
+ my $name = $attr->getName;
+ if ($name =~ /^xmlns:(.*)$/) {
+ $nsup->declare_prefix($1, $attr->getValue);
+ $child->removeAttribute($name) if ($clean);
+ }
+ }
+ }
+ print $child->getTagName, "\n";
+
my (undef, undef, $tag) = $nsup->process_element_name($child->getTagName);
my $id;
}
process($child, $obj, $clean, $nsup) unless ($processed);
+ $nsup->pop_context;
}
} elsif (ref($obj) eq 'ARRAY') { # repeat
my $doc = $node->getOwnerDocument;
}
$frag->dispose;
- $nsup->pop_context;
return;
}
clean($node, $nsup) if $clean;
- $nsup->pop_context;
}
sub clean {