--- loncom/xml/lonxml.pm 2003/05/22 21:05:01 1.257 +++ loncom/xml/lonxml.pm 2003/05/28 21:05:33 1.258 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # XML Parser Module # -# $Id: lonxml.pm,v 1.257 2003/05/22 21:05:01 albertel Exp $ +# $Id: lonxml.pm,v 1.258 2003/05/28 21:05:33 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -494,6 +494,7 @@ sub inner_xmlparse { my $finaloutput = ''; my $result; my $token; + my $dontpop=0; while ( $#$pars > -1 ) { while ($token = $$pars['-1']->get_token) { if (($token->[0] eq 'T') || ($token->[0] eq 'C') || ($token->[0] eq 'D') ) { @@ -527,28 +528,28 @@ sub inner_xmlparse { $parstack, $pars, $safeeval, $style_for_target); } } elsif ($token->[0] eq 'E') { - #clear out any tags that didn't end - while ($token->[1] ne $$stack['-1'] && ($#$stack > -1)) { - my $lasttag=$$stack[-1]; - if ($token->[1] =~ /^$lasttag$/i) { - &Apache::lonxml::warning('Using tag </'.$token->[1].'> on line '.$token->[3].' as end tag to <'.$$stack[-1].'>'); - last; - } else { - &Apache::lonxml::warning('Found tag </'.$token->[1].'> on line '.$token->[3].' when looking for </'.$$stack[-1].'> in file'); - &end_tag($stack,$parstack,$token); - } - } - if ($Apache::lonxml::usestyle && exists($$style_for_target{'/'."$token->[1]"})) { $Apache::lonxml::usestyle=0; my $string=$$style_for_target{'/'.$token->[1]}. - ''; + ''; &Apache::lonxml::newparser($pars,\$string); $Apache::lonxml::style_values=$$parstack[-1]; + $dontpop=1; } else { - $result = &callsub("end_$token->[1]", $target, $token, $stack, - $parstack, $pars,$safeeval, $style_for_target); + #clear out any tags that didn't end + while ($token->[1] ne $$stack['-1'] && ($#$stack > -1)) { + my $lasttag=$$stack[-1]; + if ($token->[1] =~ /^$lasttag$/i) { + &Apache::lonxml::warning('Using tag </'.$token->[1].'> on line '.$token->[3].' as end tag to <'.$$stack[-1].'>'); + last; + } else { + &Apache::lonxml::warning('Found tag </'.$token->[1].'> on line '.$token->[3].' when looking for </'.$$stack[-1].'> in file'); + &end_tag($stack,$parstack,$token); + } + } + $result = &callsub("end_$token->[1]", $target, $token, $stack, + $parstack, $pars,$safeeval, $style_for_target); } } else { &Apache::lonxml::error("Unknown token event :$token->[0]:$token->[1]:"); @@ -583,9 +584,10 @@ sub inner_xmlparse { } $result = ''; - if ($token->[0] eq 'E') { + if ($token->[0] eq 'E' && !$dontpop) { &end_tag($stack,$parstack,$token); } + $dontpop=0; } if ($#$pars > -1) { pop @$pars; @@ -1023,8 +1025,6 @@ sub newparser { } else { push (@Apache::lonxml::pwd, $dir); } -# &Apache::lonxml::debug("pwd:$#Apache::lonxml::pwd"); -# &Apache::lonxml::debug("pwd:$Apache::lonxml::pwd[$#Apache::lonxml::pwd]"); } sub parstring { @@ -1192,7 +1192,7 @@ sub handler { my $target=&get_target(); - $Apache::lonxml::debug=0; + $Apache::lonxml::debug=$ENV{'user.debug'}; if ($ENV{'browser.mathml'}) { $request->content_type('text/xml');