From: sgunderson@bigfoot.com <> Date: Thu, 1 Mar 2007 12:49:24 +0000 (+0100) Subject: Make perl-sax/attribute test pass. X-Git-Url: https://git.sesse.net/?p=xml-template;a=commitdiff_plain;h=10bdf091d5c5e0405489f01422d5d61abd2ff6cf Make perl-sax/attribute test pass. --- diff --git a/perl-sax/XML/TemplateSAX/Handler.pm b/perl-sax/XML/TemplateSAX/Handler.pm index a0a40b2..3ec394b 100644 --- a/perl-sax/XML/TemplateSAX/Handler.pm +++ b/perl-sax/XML/TemplateSAX/Handler.pm @@ -40,6 +40,23 @@ sub start_element { # substitution: see if this element matches anything. if so, # descend down into the tree. if (ref($obj) eq 'HASH') { + # first of all, see if we have an attribute match. + for my $key (keys %$obj) { + next unless ($key =~ /^(#?)(.*)\/(.*)$/); + my ($idmarker, $name, $attr) = ($1, $2, $3); + + if (($idmarker eq '#' && $id eq $name) || + ($idmarker ne '#' && $data->{'LocalName'} eq $name)) { + $data->{'Attributes'}->{$attr} = { + Prefix => '', + LocalName => $attr, + Name => $attr, + NamespaceURI => '', + Value => $obj->{$key} + }; + } + } + my $match = undef; for my $key (keys %$obj) { if ($key =~ /^#(.*)$/) {