XML / Style Files
XML Files
All HTML / XML files are run through the lonxml handler before
being served to a user. This allows us to rewrite many portion
of a document and to support serverside tags. There are 2 ways
to add new tags to the xml parsing engine, either through
LON-CAPA style files or by writing Perl tag handlers for the
desired tags.
Global Variables
-
$Apache::lonxml::debug - debugging control
-
@Apache::lonxml::pwd - path to the directory containing
the file currently being processed
-
@Apache::lonxml::outputstack
$Apache::lonxml::redirection - these two are used for
capturing a subset of the output for later processing, don't
touch them directly use &startredirection and &endredirection
-
$Apache::lonxml::import - controls whether the
<import> tag actually does anything
-
@Apache::lonxml::extlinks - a list of URLs that the
user is allowed to look at because of the current resource
(images, and links)
-
$Apache::lonxml::metamode - some output is turned off,
the meta target wants a specific subset, use <output> to
guarentee that the catianed data will be in the parsing output
-
$Apache::lonxml::evaluate - controls whether
run::evaluate actually derefences variable references
-
%Apache::lonxml::insertlist - data structure for edit
mode, determines what tags can go into what other tags
-
@Apache::lonxml::namespace - stores the list of tag
namespaces used in the insertlist.tab file that are currently
active, used only in edit mode.
-
$Apache::lonxml::registered - set to 1 once the remote
has been updated to know what resource we are looking at.
-
$Apache::lonxml::request - current Apache request
object, or undef
-
$Apache::lonxml::curdepth - current depth of the
overall parse depth. Will be a string like: 2_3_1 (first tag
in the third second level tag in the second toplevel tag). It
gets set by callsub, and can be used in Perl tag
implementations. It relies upon the internal globals:
@Apache::lonxml::depthcounter,
$Apache::lonxml::depth,
$Apache::lonxml::olddepth
-
$Apache::lonxml::prevent_entity_encode - By default the
xmlparser will try to rencode any 8-bit characters into HTML
Entity Codes, If this is set to a true value it will be
prevented.
-
$Apache::lonxml::errorcount - keeps count of the number
of errors generated in a parse
-
$Apache::lonxml::warningcount - keeps count of the
number of errors generated in a parse
-
$Apache::lonxml::counter
$Apache::lonxml::counter_changed - a counter used to
keep track of the number of questions asked, used currently to
track bubble numbers, Initialized off of $ENV{'form.counter'},
and writes this value to the environment if counter_changed is
true, should use the &increment_counter() function to
increment this value.
-
$Apache::lonxml::default_homework_loaded - a boolean on
wherethe the default_homework.lcpm file has been loaded into
the Safe Space, the function
&Apache::lonxml::default_homework_load()
In common usage, $Apache::lonxml::prevent_entity_encode,
$Apache::lonxml::evaluate,
$Apache::lonxml::metamode,
$Apache::lonxml::import, should never be set to a value
directly, but rather incremented when you want the effect on,
and decremented when you want the effect off.
Notable Perl subroutines
If not specified these functions are in Apache::lonxml
-
xmlparse - see the XMLPARSE figure - also not callable
from inside a tag, if one needs to restart parsing, either
create add a new LCParser to the parser stack parser using the
newparser function, or call inner_xmlparser, see the xmlparse
function in scripttag.pm
-
recurse - acts just like xmlparse, except it
doesn't do the style definition check it always calls
callsub
-
callsub - callsub looks if a perl subroutine is defined
for the current tag and calls. Otherwise it just returns the
tag as it was read in. It also will throw on a default editing
interface unless the tag has a defined subroutine that either
returns something or requests that call sub not add the
editing interface.
-
afterburn - called on the output of xmlparse, it can
add highlights, anchors, and links to regular expersion
matches to the output.
-
register_insert - builds the
%Apache::lonxml::insertlist structure of what tags can have
what other tags inside.
-
whichuser - returns a list of $symb, $courseid,
$domain, $name that is correct for calls to lonnet functions
for this setup. Uses form.grade_ parameters, if the user is
allowed to mgr in the course
-
setup_globals - initializes all lonxml globals when
xmlparse is called. If you intend to create a new target you
will likely need to tweak how the globals are setup upon start
up.
-
init_safespace - creates Holes to external functions,
creates some global variables, and set the permitted operators
of the global Safespace intepreter.
Functions Tag Handlers can use
If not specified these functions are in Apache::lonxml
Style Files
Style File specific tags
-
<definetag> - 2 arguments, name name of
new tag being defined, if proceeded with a / defining an end
tag, required; parms parameters of the new tag, the
value of these parameters can be accesed by $parametername.
-
<render> - define what the new tag does for a non meta target
-
<meta> - define what the new tag does for a meta target
-
<tex> / <web> / <latexsource> -
define what a new tag does for a specific no meta target, all
data inside a <render> is render to all targets except
when surrounded by a specific target tags.
Guy Albertelli
Last modified: Mon Oct 21 16:41:56 EDT 2002