CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

| Download

GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it

Views: 418346
1
2
2 How To Type a GAPDoc Document
3
4
In this chapter we give a more formal description of what you need to start
5
to type documentation in GAPDoc XML format. Many details were already
6
explained by example in SectionΒ 1.2 of the introduction.
7
8
We do not answer the question How to write a GAPDoc document? in this
9
chapter. You can (hopefully) find an answer to this question by studying the
10
example in the introduction, seeΒ 1.2, and learning about more details in the
11
reference ChapterΒ 3.
12
13
The definite source for all details of the official XML standard with useful
14
annotations is:
15
16
http://www.xml.com/axml/axml.html
17
18
Although this document must be quite technical, it is surprisingly well
19
readable.
20
21
22
2.1 General XML Syntax
23
24
We will now discuss the pieces of text which can occur in a general XML
25
document. We start with those pieces which do not contribute to the actual
26
content of the document.
27
28
29
2.1-1 Head of XML Document
30
31
Each XML document should have a head which states that it is an XML document
32
in some encoding and which XML-defined language is used. In case of a GAPDoc
33
document this should always look as in the following example.
34
35
 Example 
36
<?xml version="1.0" encoding="UTF-8"?>
37
<!DOCTYPE Book SYSTEM "gapdoc.dtd">
38

39
40
SeeΒ 2.1-13 for a remark on the encoding statement.
41
42
(There may be local entity definitions inside the DOCTYPE statement, see
43
SubsectionΒ 2.2-3 below.)
44
45
46
2.1-2 Comments
47
48
A comment in XML starts with the character sequence <!-- and ends with the
49
sequence -->. Between these sequences there must not be two adjacent dashes
50
--.
51
52
53
2.1-3 Processing Instructions
54
55
A processing instruction in XML starts with the character sequence <?
56
followed by a name (xml is only allowed at the very beginning of the
57
document to declare it being an XML document, see 2.1-1). After that any
58
characters may follow, except that the ending sequence ?> must not occur
59
within the processing instruction.
60
61
Β 
62
63
And now we turn to those parts of the document which contribute to its
64
actual content.
65
66
67
2.1-4 Names in XML and Whitespace
68
69
A name in XML (used for element and attribute identifiers, see below) must
70
start with a letter (in the encoding of the document) or with a colon : or
71
underscore _ character. The following characters may also be digits, dots .
72
or dashes -.
73
74
This is a simplified description of the rules in the standard, which are
75
concerned with lots of unicode ranges to specify what a letter is.
76
77
Sequences only consisting of the following characters are considered as
78
whitespace: blanks, tabs, carriage return characters and new line
79
characters.
80
81
82
2.1-5 Elements
83
84
The actual content of an XML document consists of elements. An element has
85
some content with a leading start tag (2.1-6) and a trailing end tag
86
(2.1-7). The content can contain further elements but they must be properly
87
nested. One can define elements whose content is always empty, those
88
elements can also be entered with a single combined tag (2.1-8).
89
90
91
2.1-6 Start Tags
92
93
A start-tag consists of a less-than-character < directly followed (without
94
whitespace) by an element name (seeΒ 2.1-4), optional attributes, optional
95
whitespace, and a greater-than-character >.
96
97
An attribute consists of some whitespace and then its name followed by an
98
equal sign = which is optionally enclosed by whitespace, and the attribute
99
value, which is enclosed either in single or double quotes. The attribute
100
value may not contain the type of quote used as a delimiter or the character
101
<, the character & may only appear to start an entity, seeΒ 2.1-9. We
102
describe inΒ 2.1-11 how to enter special characters in attribute values.
103
104
Note especially that no whitespace is allowed between the starting <
105
character and the element name. The quotes around an attribute value cannot
106
be omitted. The names of elements and attributes are case sensitive.
107
108
109
2.1-7 End Tags
110
111
An end tag consists of the two characters </ directly followed by the
112
element name, optional whitespace and a greater-than-character >.
113
114
115
2.1-8 Combined Tags for Empty Elements
116
117
Elements which always have empty content can be written with a single tag.
118
This looks like a start tag (seeΒ 2.1-6) except that the trailing
119
greater-than-character > is substituted by the two character sequence />.
120
121
122
2.1-9 Entities
123
124
An entity in XML is a macro for some substitution text. There are two types
125
of entities.
126
127
A character entity can be used to specify characters in the encoding of the
128
document (can be useful for entering non-ASCII characters which you cannot
129
manage to type in directly). They are entered with a sequence &#, directly
130
followed by either some decimal digits or an x and some hexadecimal digits,
131
directly followed by a semicolon ;. Using such a character entity is just
132
equivalent to typing the corresponding character directly.
133
134
Then there are references to named entities. They are entered with an
135
ampersand character & directly followed by a name which is directly followed
136
by a semicolon ;. Such entities must be declared somewhere by giving a
137
substitution text. This text is included in the document and the document is
138
parsed again afterwards. The exact rules are a bit subtle but you probably
139
want to use this only in simple cases. Predefined entities for GAPDoc are
140
described in 2.1-10 and 2.2-3.
141
142
143
2.1-10 Special Characters in XML
144
145
We have seen that the less-than-character < and the ampersand character &
146
start a tag or entity reference in XML. To get these characters into the
147
document text one has to use entity references, namely &lt; to get < and
148
&amp; to get &. Furthermore &gt; must be used to get > when the string ]]>
149
appears in element content (and not as delimiter of a CDATA section
150
explained below).
151
152
Another possibility is to use a CDATA statement explained inΒ 2.1-12.
153
154
155
2.1-11 Rules for Attribute Values
156
157
Attribute values can contain entities which are substituted recursively. But
158
except for the entities &lt; or a character entity it is not allowed that a
159
< character is introduced by the substitution (there is no XML parsing for
160
evaluating the attribute value, just entity substitutions).
161
162
163
2.1-12 CDATA
164
165
Pieces of text which contain many characters which can be misinterpreted as
166
markup can be enclosed by the character sequences <![CDATA[ and ]]>.
167
Everything between these sequences is considered as content of the document
168
and is not further interpreted as XML text. All the rules explained so far
169
in this section do not apply to such a part of the document. The only
170
document content which cannot be entered directly inside a CDATA statement
171
is the sequence ]]>. This can be entered as ]]&gt; outside the CDATA
172
statement.
173
174
 Example 
175
A nesting of tags like <a> <b> </a> </b> is not allowed.
176

177
178
179
2.1-13 Encoding of an XML Document
180
181
We suggest to use the UTF-8 encoding for writing GAPDoc XML documents. But
182
the tools described in Chapter 5 also work with ASCII or the various
183
ISO-8859-X encodings (ISO-8859-1 is also called latin1 and covers most
184
special characters for western European languages).
185
186
187
2.1-14 Well Formed and Valid XML Documents
188
189
We want to mention two further important words which are often used in the
190
context of XML documents. A piece of text becomes a well formed XML document
191
if all the formal rules described in this section are fulfilled.
192
193
But this says nothing about the content of the document. To give this
194
content a meaning one needs a declaration of the element and corresponding
195
attribute names as well as of named entities which are allowed. Furthermore
196
there may be restrictions how such elements can be nested. This definition
197
of an XML based markup language is done in a document type definition. An
198
XML document which contains only elements and entities declared in such a
199
document type definition and obeys the rules given there is called valid
200
(with respect to this document type definition).
201
202
The main file of the GAPDoc package is gapdoc.dtd. This contains such a
203
definition of a markup language. We are not going to explain the formal
204
syntax rules for document type definitions in this section. But in ChapterΒ 3
205
we will explain enough about it to understand the file gapdoc.dtd and so the
206
markup language defined there.
207
208
209
2.2 Entering GAPDoc Documents
210
211
Here are some additional rules for writing GAPDoc XML documents.
212
213
214
2.2-1 Other special characters
215
216
As GAPDoc documents are used to produce LaTeX and HTML documents, the
217
question arises how to deal with characters with a special meaning for other
218
applications (for example &, #, $, %, ~, \, {, }, _, ^, Β  (this is a
219
non-breakable space, ~ in LaTeX) have a special meaning for LaTeX and &, <,
220
> have a special meaning for HTML (and XML). In GAPDoc you can usually just
221
type these characters directly, it is the task of the converter programs
222
which translate to some output format to take care of such special
223
characters. The exceptions to this simple rule are:
224
225
 & and < must be entered as &amp; and &lt; as explained in 2.1-10.
226
227
 The content of the GAPDoc elements <M>, <Math> and <Display> is LaTeX
228
code, see 3.8.
229
230
 The content of an <Alt> element with Only attribute contains code for
231
the specified output type, see 3.9-1.
232
233
Remark: In former versions of GAPDoc one had to use particular entities for
234
all the special characters mentioned above (&tamp;, &hash;, &dollar;,
235
&percent;, &tilde;, &bslash;, &obrace;, &cbrace;, &uscore;, &circum;, &tlt;,
236
&tgt;). These are no longer needed, but they are still defined for backwards
237
compatibility with older GAPDoc documents.
238
239
240
2.2-2 Mathematical Formulae
241
242
Mathematical formulae in GAPDoc are typed as in LaTeX. They must be the
243
content of one of three types of GAPDoc elements concerned with mathematical
244
formulae: Math, Display, and M (see SectionsΒ 3.8-1 andΒ 3.8-2 for more
245
details). The first two correspond to LaTeX's math mode and display math
246
mode. The last one is a special form of the Math element type, that imposes
247
certain restrictions on the content. On the other hand the content of an M
248
element is processed in a well defined way for text terminal or HTML output.
249
The Display element also has an attribute such that its content is processed
250
as in M elements.
251
252
Note that the content of these element is LaTeX code, but the special
253
characters < and & for XML must be entered via the entities described
254
inΒ 2.1-10 or by using a CDATA statement, seeΒ 2.1-12.
255
256
257
2.2-3 More Entities
258
259
In GAPDoc there are some more predefined entities:
260
261
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
262
β”‚ &GAP; β”‚ GAP β”‚
263
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
264
β”‚ &GAPDoc; β”‚ GAPDoc β”‚
265
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
266
β”‚ &TeX; β”‚ TeX β”‚
267
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
268
β”‚ &LaTeX; β”‚ LaTeX β”‚
269
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
270
β”‚ &BibTeX; β”‚ BibTeX β”‚
271
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
272
β”‚ &MeatAxe; β”‚ MeatAxe β”‚
273
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
274
β”‚ &XGAP; β”‚ XGAP β”‚
275
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
276
β”‚ &copyright; β”‚ Β© β”‚
277
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
278
β”‚ &nbsp; β”‚ Β  β”‚
279
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
280
β”‚ &ndash; β”‚ – β”‚
281
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
282
283
Table: Predefined Entities in the GAPDoc system
284
285
286
Here &nbsp; is a non-breakable space character.
287
288
Additional entities are defined for some mathematical symbols, see 3.8 for
289
more details.
290
291
One can define further local entities right inside the head (seeΒ 2.1-1) of a
292
GAPDoc XML document as in the following example.
293
294
 Example 
295
<?xml version="1.0" encoding="UTF-8"?>
296

297
<!DOCTYPE Book SYSTEM "gapdoc.dtd"
298
 [ <!ENTITY MyEntity "some longish <E>text</E> possibly with markup">
299
 ]>
300

301
302
These additional definitions go into the <!DOCTYPE tag in square brackets.
303
Such new entities are used like this: &MyEntity;
304
305
306