--- loncom/xml/lonxml.pm 2007/02/18 02:07:11 1.438 +++ loncom/xml/lonxml.pm 2007/02/18 02:10:04 1.439 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # XML Parser Module # -# $Id: lonxml.pm,v 1.438 2007/02/18 02:07:11 albertel Exp $ +# $Id: lonxml.pm,v 1.439 2007/02/18 02:10:04 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -901,58 +901,50 @@ sub end_tag { sub initdepth { @Apache::lonxml::depthcounter=(); - $Apache::lonxml::depth=-1; - $Apache::lonxml::olddepth=-1; + undef($Apache::lonxml::last_depth_count); } my @timers; my $lasttime; -# $Apache::lonxml::depth -> current stack depth # @Apache::lonxml::depthcounter -> count of tags that exist so # far at each level -# $Apache::lonxml::olddepth -> when ascending, need to remember the count for the level below the current level (for example going from 1_2 -> 1 -> 1_3 need to rember that ) +# $Apache::lonxml::last_depth_count -> when ascending, need to +# remember the count for the level below the current level (for +# example going from 1_2 -> 1 -> 1_3 need to remember the 2 ) sub increasedepth { my ($token) = @_; - $Apache::lonxml::depth++; - $Apache::lonxml::depthcounter[$Apache::lonxml::depth]++; - if ($Apache::lonxml::depthcounter[$Apache::lonxml::depth]==1) { - $Apache::lonxml::olddepth=$Apache::lonxml::depth; - } + push(@Apache::lonxml::depthcounter,$Apache::lonxml::last_depth_count+1); + undef($Apache::lonxml::last_depth_count); my $time; if ($Apache::lonxml::debug eq "1") { push(@timers,[&gettimeofday()]); $time=&tv_interval($lasttime); $lasttime=[&gettimeofday()]; } - my $spacing=' 'x($Apache::lonxml::depth-1); + my $spacing=' 'x($#Apache::lonxml::depthcounter); $Apache::lonxml::curdepth=join('_',@Apache::lonxml::depthcounter); - &Apache::lonxml::debug("s$spacing$Apache::lonxml::depth : $Apache::lonxml::olddepth : $Apache::lonxml::curdepth : $token->[1] : $time"); +# &Apache::lonxml::debug("s$spacing$Apache::lonxml::depth : $Apache::lonxml::olddepth : $Apache::lonxml::curdepth : $token->[1] : $time"); #print "
s $Apache::lonxml::depth : $Apache::lonxml::olddepth : $curdepth : $token->[1]\n"; } sub decreasedepth { my ($token) = @_; - $Apache::lonxml::depth--; - if ($Apache::lonxml::depth<$Apache::lonxml::olddepth-1) { - $#Apache::lonxml::depthcounter--; - $Apache::lonxml::olddepth=$Apache::lonxml::depth+1; - } - if ( $Apache::lonxml::depth < -1) { - &Apache::lonxml::warning(&mt("Missing tags, unable to properly run file.")); - $Apache::lonxml::depth='-1'; + if ( $#Apache::lonxml::depthcounter == -1) { + &Apache::lonxml::warning(&mt("Missing tags, unable to properly run file.")); } + $Apache::lonxml::last_depth_count = pop(@Apache::lonxml::depthcounter); + my ($timer,$time); if ($Apache::lonxml::debug eq "1") { $timer=pop(@timers); $time=&tv_interval($lasttime); $lasttime=[&gettimeofday()]; } - my $spacing=' 'x$Apache::lonxml::depth; - $Apache::lonxml::curdepth= - join('_',@Apache::lonxml::depthcounter[0..$Apache::lonxml::depth]); - &Apache::lonxml::debug("e$spacing$Apache::lonxml::depth : $Apache::lonxml::olddepth : $Apache::lonxml::curdepth : $token->[1] : $time : ".&tv_interval($timer)); + my $spacing=' 'x($#Apache::lonxml::depthcounter); + $Apache::lonxml::curdepth = join('_',@Apache::lonxml::depthcounter); +# &Apache::lonxml::debug("e$spacing$Apache::lonxml::depth : $Apache::lonxml::olddepth : $Apache::lonxml::curdepth : $token->[1] : $time : ".&tv_interval($timer)); #print "
e $Apache::lonxml::depth : $Apache::lonxml::olddepth : $token->[1] : $curdepth\n"; }