]> git.sesse.net Git - xml-template/commitdiff
Make perl-sax/attribute test pass.
authorsgunderson@bigfoot.com <>
Thu, 1 Mar 2007 12:49:24 +0000 (13:49 +0100)
committersgunderson@bigfoot.com <>
Thu, 1 Mar 2007 12:49:24 +0000 (13:49 +0100)
perl-sax/XML/TemplateSAX/Handler.pm

index a0a40b2558ac76cc56014c0c4e3f8028d11295a4..3ec394b86b45f95e3da86abd931b8d161300c6c0 100644 (file)
@@ -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 =~ /^#(.*)$/) {