--- loncom/xml/lonxml.pm 2000/10/05 19:30:14 1.23 +++ loncom/xml/lonxml.pm 2000/10/09 14:07:02 1.24 @@ -39,6 +39,10 @@ sub xmlparse { my $finaloutput = ''; my $newarg = ''; my $result; + + my $indicator = 1; + my $pocketbox = ''; + my $safeeval = new Safe; $safeeval->permit("entereval"); $safeeval->permit(":base_math"); @@ -67,12 +71,23 @@ sub xmlparse { push (@parstack,&parstring($token)); &increasedepth($token); if (exists $style_for_target{$token->[1]}) { - $finaloutput .= &recurse($style_for_target{$token->[1]}, - $target,$safeeval,\%style_for_target, - @parstack); + + if ($indicator == 1) { + $finaloutput .= &recurse($style_for_target{$token->[1]}, + $target,$safeeval,\%style_for_target, + @parstack); + } else { + $pocketbox .= &recurse($style_for_target{$token->[1]}, + $target,$safeeval,\%style_for_target, + @parstack); + } + } else { $result = &callsub("start_$token->[1]", $target, $token,\@parstack, \@pars, $safeeval, \%style_for_target); + + if ($result eq "footnote") { &Apache::lonxml::debug($result);} + } } elsif ($token->[0] eq 'E') { #clear out any tags that didn't end @@ -80,18 +95,33 @@ sub xmlparse { && ($#stack > -1)) {pop @stack;pop @parstack;&decreasedepth($token);} if (exists $style_for_target{'/'."$token->[1]"}) { + + if ($indicator == 1) { $finaloutput .= &recurse($style_for_target{'/'."$token->[1]"}, $target,$safeeval,\%style_for_target, @parstack); + } else { + $pocketbox .= &recurse($style_for_target{'/'."$token->[1]"}, + $target,$safeeval,\%style_for_target, + @parstack); + } + } else { $result = &callsub("end_$token->[1]", $target, $token, \@parstack, \@pars,$safeeval, \%style_for_target); } } if ($result ne "" ) { - if ( $#parstack > -1 ) { + if ( $#parstack > -1 ) { + + if ($indicator == 1) { $finaloutput .= &Apache::run::evaluate($result,$safeeval, $parstack[$#parstack]); + } else { + $pocketbox .= &Apache::run::evaluate($result,$safeeval, + $parstack[$#parstack]); + } + } else { $finaloutput .= &Apache::run::evaluate($result,$safeeval,''); } @@ -102,6 +132,7 @@ sub xmlparse { pop @pars; pop @Apache::lonxml::pwd; } + return $finaloutput; } @@ -168,13 +199,20 @@ sub callsub { my ($sub,$target,$token,$parstack,$parser,$safeeval,$style)=@_; my $currentstring=''; { + my $sub1; no strict 'refs'; if (my $space=$Apache::lonxml::alltags{$token->[1]}) { - #&Apache::lonxml::debug("Calling sub $sub in $space
\n"); - $sub="$space\:\:$sub"; +# &Apache::lonxml::debug("Calling sub $sub in $space
\n"); +# if ( $sub eq "start_parserlib" ) { +# print "me:".%$style.":\n"; +# } + $sub1="$space\:\:$sub"; $Apache::lonxml::curdepth=join('_',@Apache::lonxml::depthcounter); - $currentstring = &$sub($target,$token,$parstack,$parser, + $currentstring = &$sub1($target,$token,$parstack,$parser, $safeeval,$style); +# if ( $sub eq "start_parserlib" ) { +# print "me2:".%$style.":"; +# } } else { #&Apache::lonxml::debug("NOT Calling sub $sub in $space
\n"); if (defined($token->[4])) { @@ -220,6 +258,8 @@ sub get_all_text { my $depth=0; my $token; my $result=''; + my $tag=substr($tag,1); #strip the / off the tag +# &Apache::lonxml::debug("have:$tag:"); while (($depth >=0) && ($token = $pars->get_token)) { if ($token->[0] eq 'T') { $result.=$token->[1]; @@ -227,7 +267,7 @@ sub get_all_text { if ($token->[1] eq $tag) { $depth++; } $result.=$token->[4]; } elsif ($token->[0] eq 'E') { - if ($token->[1] eq $tag) { $depth--; } + if ( $token->[1] eq $tag) { $depth--; } #skip sending back the last end tag if ($depth > -1) { $result.=$token->[2]; } } @@ -257,7 +297,32 @@ sub parstring { } @{$token->[3]}; return $temp; } +#<<<<<<< lonxml.pm +sub handler { + my $request=shift; + + my $target='web'; + $Apache::lonxml::debug=1; + $request->content_type('text/html'); + $request->send_http_header; + $request->print(< + +Just test + + +ENDHEADER +# &Apache::lonhomework::send_header($request); + my $file = "/home/httpd/html".$request->uri; + my %mystyle; + my $result = ''; + $result = Apache::lonxml::xmlparse($target, &Apache::lonnet::getfile($file),'',%mystyle); +# $request->print("Result follows:"); + $request->print($result); +# $request->print(":Result ends"); +} + $Apache::lonxml::debug=0; sub debug { if ($Apache::lonxml::debug eq 1) {