Diff for /loncom/xml/lonxml.pm between versions 1.16 and 1.17

version 1.16, 2000/08/03 19:34:11 version 1.17, 2000/08/08 19:34:29
Line 45  sub xmlparse { Line 45  sub xmlparse {
   
  my @stack = ();    my @stack = (); 
  my @parstack = ();   my @parstack = ();
    &initdepth;
  my $token;   my $token;
  print $#pars;  
  while ( $#pars > -1 ) {   while ( $#pars > -1 ) {
    while ($token = $pars[$#pars]->get_token) {     while ($token = $pars[$#pars]->get_token) {
      if ($token->[0] eq 'T') {       if ($token->[0] eq 'T') {
Line 57  sub xmlparse { Line 57  sub xmlparse {
        push (@stack,$token->[1]);         push (@stack,$token->[1]);
        # add parameters list to another stack         # add parameters list to another stack
        push (@parstack,&parstring($token));         push (@parstack,&parstring($token));
                 &increasedepth();       
        if (exists $style_for_target{$token->[1]}) {         if (exists $style_for_target{$token->[1]}) {
  $finaloutput .= &recurse($style_for_target{$token->[1]},   $finaloutput .= &recurse($style_for_target{$token->[1]},
   $target,$safeeval,\%style_for_target,    $target,$safeeval,\%style_for_target,
   @parstack);    @parstack);
        } else {         } else {
  my $result = &callsub("start_$token->[1]", $target, $token,\@parstack,   $result = &callsub("start_$token->[1]", $target, $token,\@parstack,
        \@pars, $safeeval, \%style_for_target);         \@pars, $safeeval, \%style_for_target);
        }                       }              
      } elsif ($token->[0] eq 'E')  {       } elsif ($token->[0] eq 'E')  {
        #clear out any tags that didn't end         #clear out any tags that didn't end
        while ($token->[1] ne $stack[$#stack]          while ($token->[1] ne $stack[$#stack] 
       && ($#stack > -1)) {pop @stack;pop @parstack;}        && ($#stack > -1)) {pop @stack;pop @parstack;&decreasedepth;}
                 
        if (exists $style_for_target{'/'."$token->[1]"}) {         if (exists $style_for_target{'/'."$token->[1]"}) {
  $finaloutput .= &recurse($style_for_target{'/'."$token->[1]"},   $finaloutput .= &recurse($style_for_target{'/'."$token->[1]"},
   $target,$safeeval,\%style_for_target,    $target,$safeeval,\%style_for_target,
   @parstack);    @parstack);
        } else {         } else {
  my $result = &callsub("end_$token->[1]", $target, $token, \@parstack,   $result = &callsub("end_$token->[1]", $target, $token, \@parstack,
        \@pars,$safeeval, \%style_for_target);         \@pars,$safeeval, \%style_for_target);
        }         }
      }       }
Line 89  sub xmlparse { Line 89  sub xmlparse {
        }         }
        $result = '';         $result = '';
      }       }
      if ($token->[0] eq 'E') { pop @stack;pop @parstack; }       if ($token->[0] eq 'E') { pop @stack;pop @parstack;&decreasedepth;}
    }     }
    pop @pars;     pop @pars;
  }   }
Line 114  sub recurse { Line 114  sub recurse {
       } elsif ($tokenpat->[0] eq 'S') {        } elsif ($tokenpat->[0] eq 'S') {
  push (@innerstack,$tokenpat->[1]);   push (@innerstack,$tokenpat->[1]);
  push (@innerparstack,&parstring($tokenpat));   push (@innerparstack,&parstring($tokenpat));
    &increasedepth();
  $partstring = &callsub("start_$tokenpat->[1]",    $partstring = &callsub("start_$tokenpat->[1]", 
        $target, $tokenpat, \@innerparstack,         $target, $tokenpat, \@innerparstack,
        \@pat, $safeeval, $style_for_target);         \@pat, $safeeval, $style_for_target);
       } elsif ($tokenpat->[0] eq 'E') {        } elsif ($tokenpat->[0] eq 'E') {
  #clear out any tags that didn't end   #clear out any tags that didn't end
  while ($tokenpat->[1] ne $innerstack[$#innerstack]    while ($tokenpat->[1] ne $innerstack[$#innerstack] 
        && ($#innerstack > -1)) {pop @innerstack;pop @innerparstack;}         && ($#innerstack > -1)) {pop @innerstack;pop @innerparstack;
    &decreasedepth;}
  $partstring = &callsub("end_$tokenpat->[1]",   $partstring = &callsub("end_$tokenpat->[1]",
        $target, $tokenpat, \@innerparstack,         $target, $tokenpat, \@innerparstack,
        \@pat, $safeeval, $style_for_target);         \@pat, $safeeval, $style_for_target);
Line 144  sub recurse { Line 146  sub recurse {
  $output .= &Apache::run::evaluate($partstring,$safeeval,$decls);   $output .= &Apache::run::evaluate($partstring,$safeeval,$decls);
  $partstring = '';   $partstring = '';
       }        }
       if ($tokenpat->[0] eq 'E') { pop @innerstack;pop @innerparstack; }        if ($tokenpat->[0] eq 'E') { pop @innerstack;pop @innerparstack;
    &decreasedepth;}
     }      }
     pop @pat;      pop @pat;
   }    }
Line 159  sub callsub { Line 162  sub callsub {
     if (my $space=$Apache::lonxml::alltags{$token->[1]}) {      if (my $space=$Apache::lonxml::alltags{$token->[1]}) {
       #print "Calling sub $sub in $space \n";        #print "Calling sub $sub in $space \n";
       $sub="$space\:\:$sub";        $sub="$space\:\:$sub";
         $Apache::lonxml::curdepth=join('_',@Apache::lonxml::depthcounter);
       $currentstring = &$sub($target,$token,$parstack,$parser,        $currentstring = &$sub($target,$token,$parstack,$parser,
      $safeeval,$style);       $safeeval,$style);
     } else {      } else {
Line 174  sub callsub { Line 178  sub callsub {
   return $currentstring;    return $currentstring;
 }  }
   
   sub initdepth {
     @Apache::lonxml::depthcounter=();
     $Apache::lonxml::depth=-1;
     $Apache::lonxml::olddepth=-1;
   }
   
   sub increasedepth {
     if ($Apache::lonxml::depth<$Apache::lonxml::olddepth-1) {
       $#Apache::lonxml::depthcounter--;
       $Apache::lonxml::olddepth=$Apache::lonxml::depth;
     }
     $Apache::lonxml::depth++;
     $Apache::lonxml::depthcounter[$Apache::lonxml::depth]++;
     if ($Apache::lonxml::depthcounter[$Apache::lonxml::depth]==1) {
       $Apache::lonxml::olddepth=$Apache::lonxml::depth;
     }
   }
   
   sub decreasedepth {
     $Apache::lonxml::depth--;
   }
   
 sub parstring {  sub parstring {
   my ($token) = @_;    my ($token) = @_;
   my $temp='';    my $temp='';

Removed from v.1.16  
changed lines
  Added in v.1.17


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>