--- loncom/xml/lonxml.pm 2001/05/04 17:33:35 1.70
+++ loncom/xml/lonxml.pm 2023/11/28 04:48:14 1.567
@@ -1,522 +1,1425 @@
# The LearningOnline Network with CAPA
# XML Parser Module
#
-# last modified 06/26/00 by Alexander Sakharuk
-# 11/6 Gerd Kortemeyer
-# 6/1/1 Gerd Kortemeyer
-# 2/21,3/13 Guy
-# 3/29,5/4 Gerd Kortemeyer
+# $Id: lonxml.pm,v 1.567 2023/11/28 04:48:14 raeburn Exp $
+#
+# Copyright Michigan State University Board of Trustees
+#
+# This file is part of the LearningOnline Network with CAPA (LON-CAPA).
+#
+# LON-CAPA is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# LON-CAPA is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with LON-CAPA; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# /home/httpd/html/adm/gpl.txt
+#
+# http://www.lon-capa.org/
+#
+# Copyright for TtHfunc and TtMfunc by Ian Hutchinson.
+# TtHfunc and TtMfunc (the "Code") may be compiled and linked into
+# binary executable programs or libraries distributed by the
+# Michigan State University (the "Licensee"), but any binaries so
+# distributed are hereby licensed only for use in the context
+# of a program or computational system for which the Licensee is the
+# primary author or distributor, and which performs substantial
+# additional tasks beyond the translation of (La)TeX into HTML.
+# The C source of the Code may not be distributed by the Licensee
+# to any other parties under any circumstances.
+#
-package Apache::lonxml;
-use vars
-qw(@pwd @outputstack $redirection $import @extlinks $metamode);
-use strict;
-use HTML::TokeParser;
-use Safe;
-use Safe::Hole;
-use Opcode;
-use Apache::Constants qw(:common);
+=pod
+=head1 NAME
-sub xmlbegin {
- my $output='';
- if ($ENV{'browser.mathml'}) {
- $output=''
- .''
- .']>'
- .'';
- } else {
- $output='';
- }
- return $output;
-}
+Apache::lonxml
-sub xmlend {
- return '';
-}
+=head1 SYNOPSIS
-sub fontsettings() {
- my $headerstring='';
- if (($ENV{'browser.os'} eq 'mac') && (!$ENV{'browser.mathml'})) {
- $headerstring.=
- '';
- }
- return $headerstring;
-}
-
-sub registerurl {
- return (<
- function LONCAPAreg() {
- if (window.location.pathname!="/res/adm/pages/menu.html") {
- menu=window.open("","LONCAPAmenu");
- menu.currentURL=window.location.pathname;
- menu.currentStale=0;
- }
- }
-
- function LONCAPAstale() {
- if (window.location.pathname!="/res/adm/pages/menu.html") {
- menu=window.open("","LONCAPAmenu");
- menu.currentStale=1;
- }
- }
-
-ENDSCRIPT
-}
+XML Parsing Module
-sub loadevents() {
- return 'LONCAPAreg();';
-}
+This is part of the LearningOnline Network with CAPA project
+described at http://www.lon-capa.org.
-sub unloadevents() {
- return 'LONCAPAstale();';
-}
+
+=head1 SUBROUTINES
+
+=cut
+
+
+
+package Apache::lonxml;
+use vars
+qw(@pwd @outputstack $redirection $import @extlinks $metamode $evaluate %insertlist @namespace $errorcount $warningcount);
+use strict;
+use LONCAPA;
+use HTML::LCParser();
+use HTML::TreeBuilder();
+use HTML::Entities();
+use Safe();
+use Safe::Hole();
+use Math::Cephes();
+use Math::Random();
+use Math::Calculus::Expression();
+use Number::FormatEng();
+use Opcode();
+use POSIX qw(strftime);
+use Time::HiRes qw( gettimeofday tv_interval );
+use Symbol();
sub register {
- my $space;
- my @taglist;
- my $temptag;
- ($space,@taglist) = @_;
- foreach $temptag (@taglist) {
- $Apache::lonxml::alltags{$temptag}=$space;
+ my ($space,@taglist) = @_;
+ foreach my $temptag (@taglist) {
+ push(@{ $Apache::lonxml::alltags{$temptag} },$space);
}
}
-sub printalltags {
- my $temp;
- foreach $temp (sort keys %Apache::lonxml::alltags) {
- &Apache::lonxml::debug("$temp -- $Apache::lonxml::alltags{$temp}");
+sub deregister {
+ my ($space,@taglist) = @_;
+ foreach my $temptag (@taglist) {
+ my $tempspace = $Apache::lonxml::alltags{$temptag}[-1];
+ if ($tempspace eq $space) {
+ pop(@{ $Apache::lonxml::alltags{$temptag} });
+ }
}
+ #&printalltags();
}
-use Apache::style;
-use Apache::run;
-use Apache::londefdef;
-use Apache::scripttag;
-use Apache::edit;
-#================================================== Main subroutine: xmlparse
+
+use Apache::Constants qw(:common);
+use Apache::lontexconvert();
+use Apache::style();
+use Apache::run();
+use Apache::londefdef();
+use Apache::scripttag();
+use Apache::languagetags();
+use Apache::edit();
+use Apache::inputtags();
+use Apache::outputtags();
+use Apache::lonnet;
+use Apache::File();
+use Apache::loncommon();
+use Apache::lonfeedback();
+use Apache::lonmsg();
+use Apache::loncacc();
+use Apache::lonmaxima();
+use Apache::lonr();
+use Apache::lonlocal;
+use Apache::lonhtmlcommon();
+use Apache::functionplotresponse();
+use Apache::lonnavmaps();
+
+#==================================== Main subroutine: xmlparse
+
+#debugging control, to turn on debugging modify the correct handler
+
+$Apache::lonxml::debug=0;
+
+# keeps count of the number of warnings and errors generated in a parse
+$warningcount=0;
+$errorcount=0;
+
+#path to the directory containing the file currently being processed
@pwd=();
+
+#these two are used for capturing a subset of the output for later processing,
+#don't touch them directly use &startredirection and &endredirection
@outputstack = ();
$redirection = 0;
+
+#controls wheter the tag actually does
$import = 1;
@extlinks=();
+
+# meta mode is a bit weird only some output is to be turned off
+#