• No results found

Transformation Tools for Annotated Document

ment

One of the aims of MathLang framework is to allow further manipulations of the MathLang encoded document. This is easily possible due to the internal XML presentation of MathLang encoded documents. The use of the XML standards allows to apply XSL stylesheets to the MathLang document. This section presents the transformation files written to generate different views of a MathLang encoded document. We concentrate here on the development of stylesheet files for the MathLang DRa aspect that allow to transform the DRa annotation into graph presentation.

6.3.1

The XSL Transformations

XML documents can be transformed to any desired presentation and format by applying the appropriate stylesheet written in XSL14 Transformations (XSLT) lan-

14

“The Extensible Stylesheet Lanugage is a family of recommendations for defining XML doc- ument transformation and presentation.” (according to http://www.w3.org/Style/XSL/).

guage. The XSLT is a language that allows to define transformation and presenta- tion rules for an XML document. The XSLT uses the XML Path Language (XPath) – an expression language – to access or refer to parts of an XML document.

We developed a number of XSLT stylesheets to transform the MathLang DRa annotated document into different graph representations, like the Dependency Graph and the Graph of Logical Precedences. As an output of the XSLT transfor- mations of the MathLang DRa document we get the description of a graph written in the DOT language15. Later on the produced .dot file16, which stores the de-

scription of our graph, is passed to a computer program called dot to generate the Postscript file with a visual presentation of the graph. The dot computer program is part of the Graphviz layout package. The Graphviz takes descriptions of graphs in a text language and generates diagrams in several useful formats such as images, SVG, Postscript files etc.

Figure B.1 presents fragment of the XSLT stylesheet developed to transform MathLang DRa annotated relations into the description of the dependency graph in the DOT language.

All presented graphs in this thesis have been produced automatically by apply- ing appropriate XSLT stylesheets, sometimes also written for the LATEX annotated

document. The next section will present how we use the DOT language and the transformation technology to generate graphs directly from the TEXmacs annota- tion.

6.3.2

The Scheme Implementation for Generating Graphs

The internal presentation of a TEXmacs document has an XML-like tree structure even though it uses different entities, see Listing 2.2. Furthermore, the TEXmacs Schemeimplementation and functions allow to access each node of that document tree and transform it into another presentation. As a result, it provides a simple way to build a transformation file for the TEXmacs annotated document and finally for the MathLang encoded document in TEXmacs. However, the transformation functions and rules have to be written in Scheme and have to be integrated as an extension/plugin for TEXmacs.

We developed the transformation rules for the MathLang DRa encoded docu-

15The DOT language allows in a simple and easy way to describe graphs that both humans

and computer can use. It has a very small abstract grammar http://www.graphviz.org/doc/ info/lang.html

16

ment, that allow to retrieve MathLang DRa annotation and build the description of DRa graphs in the DOT language. Moreover, such generated description is passed to the external computer program (called DOT) to compile and build the visual presentation of the graph in the form of a Postscript file. Once the Postscript file is generated it is passed to the gv program to display that file.

We integrated these transformation rules and functions within

the mathlang-dra-graphs.scm file of the MathLang plugin. It actually follows a similar approach to the described above XSLT transformation files. Each time we call the function, from the MathLang-DRa menu to generate the graph pre- sentation, it walks through the TEXmacs tree and builds an appropriate graph presentation in the DOT language. Figure B.2 presents the fragment of a function responsible for building the DG graph from the annotation. Figure 6.10 presents the automatically generated description of the graph for the Pythagoras Theorem example (see Figure 4.6) which is built from the DRa annotated MathLang docu- ment as presented in Figure A.6. Finally, Figure 6.9 presents two possible views of the DG graph of the document, generated automatically from the TEXmacs edi- tor. The lefthand side of that Figure presents only id’s and relations from the DRa document, whereas the righthand side of the Figure presents the full annotation information including structural and mathematical roles.

DRa Dependency Graph -- simple. Presents only lociid and relations from DRa annotation. B A justifies D uses C justifies G F justifies E uses uses H subpartOf uses I subpartOf

DRa Dependency Graph -- comprehensive. Presents all data from DRa annotation. B proof A lemma justifies D proof uses C corollary justifies G proof F claim justifies E proof uses uses H case subpartOf uses I case subpartOf

Figure 6.9: The presentation of the DRa Dependency Graph generated automati- cally from the TEXmacs, by the use of functions from the MathLang-DRa menu.

Figure 6.10: The .dot file generated automatically by the MathLang DRa part of the TEXmacs plugin. It consists of a description of the DRa Dependency Graph comprehensive view, see the righthand side of Figure 6.9.