]> git.sesse.net Git - xml-template/commitdiff
Fix some internal oddities in perl-sax/structure; however, the test still
authorsgunderson@bigfoot.com <>
Thu, 1 Mar 2007 14:06:30 +0000 (15:06 +0100)
committersgunderson@bigfoot.com <>
Thu, 1 Mar 2007 14:06:30 +0000 (15:06 +0100)
does not pass.

perl-sax/XML/TemplateSAX/Handler.pm

index 72a506c36db51d6596b55f5ecac3be88c677e321..b7917bc7979b2101156ab4525f3d6c5ff405cf74 100644 (file)
@@ -23,34 +23,11 @@ sub new {
 sub start_element {
        my ($self, $data) = @_;
        my $obj = $self->{'obj'};
-
+       
        # find the ID, if any
        my $id = $data->{'Attributes'}->{'{http://template.sesse.net/}id'};
        $id = $id->{'Value'} if (defined($id));
 
-       # 
-       # If we have multiple elements with the same name within each other,
-       # we need to keep track of how many there are, so check here and increment.
-       # end_element will decrement and optionally pop the stack.
-       #
-       my $stack = $self->{'stack'};
-       if (scalar @$stack > 0) {
-               my $top = $stack->[scalar @$stack - 1];
-
-               if ($data->{'Name'} eq $top->[0]) {
-                       ++$top->[1];
-               }
-       }
-
-       # within a replacement; just ignore everything  
-       return if (!defined($obj));
-
-       # within a cloning; slurp it up
-       if (ref($obj) eq 'XML::TemplateSAX::Buffer') {
-               $obj->start_element($data);
-               return;
-       }
-
        # substitution: see if this element matches anything. if so,
        # descend down into the tree.
        if (ref($obj) eq 'HASH') {
@@ -131,6 +108,28 @@ sub start_element {
                }
        }
        
+       # 
+       # If we have multiple elements with the same name within each other,
+       # we need to keep track of how many there are, so check here and increment.
+       # end_element will decrement and optionally pop the stack.
+       #
+       my $stack = $self->{'stack'};
+       if (scalar @$stack > 0) {
+               my $top = $stack->[scalar @$stack - 1];
+
+               if ($data->{'Name'} eq $top->[0]) {
+                       ++$top->[1];
+               }
+       }
+
+       # within a replacement; just ignore everything  
+       return if (!defined($obj));
+
+       # within a cloning; slurp it up
+       if (ref($obj) eq 'XML::TemplateSAX::Buffer') {
+               $obj->start_element($data);
+               return;
+       }
 
        $self->SUPER::start_element($data);
 }
@@ -176,7 +175,7 @@ sub processing_instruction {
 
 sub end_element {
        my ($self, $data) = @_;
-
+       
        my $stack = $self->{'stack'};
        if (scalar @$stack > 0) {
                my $top = $stack->[scalar @$stack - 1];