Anastasia home

How Anastasia works: the processing model

This is what happens when the reader asks Anastasia to process some XML.

A call is sent from the browser to the Anastasia server. The call has the form "http://www.myserver /AnaServer?MyBook+0+start.anv". The call is received by the host Apache server "www.myserver" (which in CD-ROM mode will be running on the local machine):

Processing one page of text

What happens next depends on the starting element and what is found in the 'anv' file. Here is a fairly typical scenario, for any page of a manuscript transcription presented in the Miller's Tale on CD-ROM (see further the SDE website):

Many other things can happen in the course of reading the page. Because it is a medieval text, there will be many non-standard characters. Each time Anastasia meets one it generates an SDATA event, and checks if there is a SDATA procedure for that character to define how it should be written to the browser. Or, the page may be called following a search, requiring that some of the text be highlighted. Anastasia will generate events for the start and end of each hit, and again look in the .anv file for a "found" procedure defining how the hits should be presented.

How is this all managed?

The keys to all this, from the developer's perspective, are the .anv files for the electronic book. These are written in Tcl ("Tool control language"): a very widely supported scripting language with implementations on all major computer platforms. Tcl is easy to learn and easy to use (some would say, too easy). In Tcl you can set up loops, if/then/else and switch/case statements, do string searches and replacements, have global and local variables, look up values in other files and include other files, and much more. Anastasia extends the standard Tcl environment by providing some thirty extension commands, which allow you to look up any element within the XML, examine its properties, navigate around it, and search for it or for any text, all from within any procedure within the .anv file. A typical Anastasia statement in an .anv file looks like so:

if {[attr $me rend=="ital"} {set text "<I>"}

This checks the value of the "rend" attribute on the current element being processed ($me): if it is "ital", then "<I>" is written out to the browser.

By design, Anastasia does all this in real time, in direct response to a user request. Therefore, it has to be able to get what it wants from the XML very fast, no matter how large the XML or where it is in the XML. It does this by interrogating not the source XML but a set of binary files (an "AnaGrove") which are optimized to permit the fastest access to information about every aspect of the source XML.

In summary...

You could characterize Anastasia as an event-driven procedural environment for handling XML document collections. As such, it is very different from such tools as XSLT. See also "How Anastasia differs from XSLT".