cHawk |
cHawk is an application made to publish active mathematical documents. It consists of three major modules or interfaces
The live mathematical formulas, calculations and graphs in the document form its skeleton, common to every language versions. The explanatory texts between them are taken from the database. The advantage of this idea is that if one publishes a document in some language another person can add into the database the explanatory texts in a different language using a friendly web browser form.
In my presentation I'll first demonstrate the use of different moduls, then explain the technology in general and finally show the details of the code of the end user interface.
Java Server Pages (JSP) are normal HTML pages that have some additional container tags. The server side preprosessor interprets that content of the text and replaces it with standard HTML syntax before sending the page to browser. The JSP standard allows users to install personal tags for dedicated use. One such special tag is <%Mathlet %> , made by Wolfram Research Inc. (WRI), the creator of Mathematica. The content of Mathlet tag consists of Mathematica commands. JSP files containing Mathlet tags are called MSP files (Mathematica Server Pages).
For example the server side preprocessor modifies following MSP code...
...to the form below before responding to the client's request.
The final end users view is shown below.
All MSP files in cHawk have common initialization commands. They are arranged into an auxiliary m-file util2.m. The commands in that file:
Let's have a look at one of the MSP files. That file plots the graph of y = f(x).
The first Mathlet
<%Mathlet document=51; Get["../util2.m"]; %>
initializes the Java object ph and loads the texts of the document 51 from the database into ph
written in the desired language.
Next Mathlet
<%Mathlet ph@getPhtx[] %>
replaces itself with the first text 'Plot of y = f(x)'
taken from the Java object ph.
Next two Mathlets
<%Mathlet ph@getPhtx[] %>
and
<input type = "text"
size = "24"
name = "fun"
value = "<%Mathlet MSPValue[ $$fun, "Sin[x]^2"] %>"
>
create the second text 'f[x] using Mathematica syntax'
and the value of the variable $$fun.
If it doesn't have a value, the expression Sin[x]^2 will be shown.
And this happens when you enter this page for first time.
The second last Mathlet
<input type="submit" value = "<%Mathlet ph@getPhtx[] %>">
creates the text of the submit button
In the DC table there exists one row per one MSP file.
DE table divides a document into ordered fragments called Document Elements.
TX table contains the texts.
LG table contains the possible languages for translations.
PE table contains the permissions to edit translations.
US table contains user information. USRO is user's role, namely translator or system administrator.