--- loncom/xml/lonxml.pm 2001/11/29 19:03:58 1.139 +++ loncom/xml/lonxml.pm 2001/11/29 21:38:17 1.140 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # XML Parser Module # -# $Id: lonxml.pm,v 1.139 2001/11/29 19:03:58 www Exp $ +# $Id: lonxml.pm,v 1.140 2001/11/29 21:38:17 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -463,11 +463,11 @@ sub htmlclean { my $tree = HTML::TreeBuilder->new; $tree->ignore_unknown(0); - + $tree->parse($raw); my $output= $tree->as_HTML(undef,' '); - + $output=~s/\<(br|hr|img|meta|allow)([^\>\/]*)\>/\<$1$2 \/\>/gis; $output=~s/\<\/(br|hr|img|meta|allow)\>//gis; unless ($full) { @@ -495,14 +495,14 @@ sub inner_xmlparse { $result=$token->[2]; } } elsif ($token->[0] eq 'S') { - # add tag to stack + # add tag to stack push (@$stack,$token->[1]); # add parameters list to another stack push (@$parstack,&parstring($token)); - &increasedepth($token); + &increasedepth($token); if (exists $$style_for_target{$token->[1]}) { if ($Apache::lonxml::redirection) { - $Apache::lonxml::outputstack['-1'] .= + $Apache::lonxml::outputstack['-1'] .= &recurse($$style_for_target{$token->[1]},$target,$safeeval, $style_for_target,@$parstack); } else { @@ -512,15 +512,15 @@ sub inner_xmlparse { } else { $result = &callsub("start_$token->[1]", $target, $token, $stack, $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)) { - &Apache::lonxml::warning("Unbalanced tags in resource $$stack['-1']"); + &Apache::lonxml::warning('Missing tag </'.$$stack['-1'].'> in file'); &end_tag($stack,$parstack,$token); } - - if (exists $$style_for_target{'/'."$token->[1]"}) { + + if (exists($$style_for_target{'/'."$token->[1]"})) { if ($Apache::lonxml::redirection) { $Apache::lonxml::outputstack['-1'] .= &recurse($$style_for_target{'/'."$token->[1]"}, @@ -530,7 +530,6 @@ sub inner_xmlparse { $target,$safeeval,$style_for_target, @$parstack); } - } else { $result = &callsub("end_$token->[1]", $target, $token, $stack, $parstack, $pars,$safeeval, $style_for_target); @@ -581,6 +580,7 @@ sub recurse { my $partstring = ''; my $output=''; my $decls=''; + &Apache::lonxml::debug("Recursing"); while ( $#pat > -1 ) { while ($tokenpat = $pat[$#pat]->get_token) { if (($tokenpat->[0] eq 'T') || ($tokenpat->[0] eq 'C') || ($tokenpat->[0] eq 'D') ) { @@ -598,7 +598,7 @@ sub recurse { #clear out any tags that didn't end while ($tokenpat->[1] ne $innerstack[$#innerstack] && ($#innerstack > -1)) { - &Apache::lonxml::warning("Unbalanced tags in resource $innerstack['-1']"); + &Apache::lonxml::warning('Missing tag </'.$innerstack['-1'].'> in style'); &end_tag(\@innerstack,\@innerparstack,$tokenpat); } $partstring = &callsub("end_$tokenpat->[1]", $target, $tokenpat, @@ -632,6 +632,7 @@ sub recurse { pop @pat; pop @Apache::lonxml::pwd; } + &Apache::lonxml::debug("Exiting Recursing"); return $output; } @@ -843,7 +844,7 @@ sub decreasedepth { $Apache::lonxml::olddepth=$Apache::lonxml::depth+1; } if ( $Apache::lonxml::depth < -1) { - &Apache::lonxml::warning("Unbalanced tags in resource"); + &Apache::lonxml::warning("Missing tags, unable to properly run file."); $Apache::lonxml::depth='-1'; } my $curdepth=join('_',@Apache::lonxml::depthcounter);