Changes

Jump to navigation Jump to search
853 bytes added ,  20:14, 8 June 2020
m
no edit summary
== General ==
TEI (Text Encoding Initiative) is "a consortium which collectively develops and maintains a standard for the representation of texts in digital form," to quote [http://www.tei-c.org/index.xml their own website]. They have developed a series of guidelines for editing texts in a digital form. In their latest form (which is called P 5), these guidelines weigh in at a hefty 1350 pages (OK, that's counting the bibliography and the index too; there are only 1290 pages of real text). These describe an xml format which is suitable for editing texts. The TEI guidelines have the advantage of being very well documented. There are a number of free resources available that should help everyone who is interested in getting started (one extremely helpful website with lots of tutorials, examples, and tests is [http://tbeteibyexample.kantl.be/TBE org TEI by example]). They are not (and do not aspire to be) an absolute standard that everyone has to follow, but many academic projects use these guidelines, and they should be a pretty good way to make sure that your electronic edition of a text will be useful in the future.
Since editing texts is something which quite a few users of ConTeXt are involved in, it makes sense to think about ways in which xml documents which follow the TEI guidelines can be typeset with ConTeXt. We would invite users to keep a few caveats in mind:
== The ConTeXt style file ==
 
'''NB:''' Some of the functionality described here has been introduced quite recently. You will need a ConTeXt version not earlier than December 2010 in order to try this example!
In order to typeset such a file with ConTeXt, we need a style file which will map xml elements and attributes to specific ConTeXt commands. We have to save this file (let's call it tei-style.tex) somewhere where ConTeXt can find it (e.g., somewhere in your personal texmf tree or in the same directory as the xml file) and then typeset with the command <tt>context --environment=tei-style philostratus.xml</tt>. We will look at this file in detail:
Olearius numbers in square brackets, I needed to take a two-step approach
(the square brackets would be confusing to the ConTeXt parser). So I first
define an inmargin <texcode>\Zolearius</texcode> and then a macro<texcode>\Olearius</texcode> which takes this value and typesets it within square
brackets, in the outer margin, at a distance of 2em from the main text:
{\Olearius{\xmlatt{#1}{n}}}
{}
\stopxmlsetups
\defineinmargin [ZOlearius] [outer] [normal] [distance=2em,style=small]
</texcode>
[[User:Thomas|Thomas]] 21:3138, 7 November 2010 (UTC) == Removing unwanted strings from xml source == In some cases you might want to remove strings or characters from the xml source. For example ConTeXt cannot process a hashmark. The following example shows how to remove the hashmark from a xml identifier before processing with the command \cldcontext The xml source: <xmlcode><a href="#myspecialid">the previous section</a></xmlcode> The setup code: <texcode>\startxmlsetups xml:initialize \xmlsetsetup{#1}{a}{xml:*}\stopxmlsetups \xmlregistersetup{xml:initialize} \startxmlsetups xml:a \cldcontext{string.sub([[\xmlatt{#1}{href}]],2)}\stopxmlsetups</texcode> [[Category:XML]]

Navigation menu