Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
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
Project: cocalc-sagemath-dev-slelievre
Views: 4183461[1X2 [33X[0;0YHow To Type a [5XGAPDoc[105X[101X[1X Document[133X[101X23[33X[0;0YIn this chapter we give a more formal description of what you need to start4to type documentation in [5XGAPDoc[105X XML format. Many details were already5explained by example in SectionΒ [14X1.2[114X of the introduction.[133X67[33X[0;0YWe do [13Xnot[113X answer the question [21XHow to [13Xwrite[113X a [5XGAPDoc[105X document?[121X in this8chapter. You can (hopefully) find an answer to this question by studying the9example in the introduction, seeΒ [14X1.2[114X, and learning about more details in the10reference ChapterΒ [14X3[114X.[133X1112[33X[0;0YThe definite source for all details of the official XML standard with useful13annotations is:[133X1415[33X[0;0Y[7Xhttp://www.xml.com/axml/axml.html[107X[133X1617[33X[0;0YAlthough this document must be quite technical, it is surprisingly well18readable.[133X192021[1X2.1 [33X[0;0YGeneral XML Syntax[133X[101X2223[33X[0;0YWe will now discuss the pieces of text which can occur in a general XML24document. We start with those pieces which do not contribute to the actual25content of the document.[133X262728[1X2.1-1 [33X[0;0YHead of XML Document[133X[101X2930[33X[0;0YEach XML document should have a head which states that it is an XML document31in some encoding and which XML-defined language is used. In case of a [5XGAPDoc[105X32document this should always look as in the following example.[133X3334[4X[32X Example [32X[104X35[4X[28X<?xml version="1.0" encoding="UTF-8"?>[128X[104X36[4X[28X<!DOCTYPE Book SYSTEM "gapdoc.dtd">[128X[104X37[4X[32X[104X3839[33X[0;0YSeeΒ [14X2.1-13[114X for a remark on the [21Xencoding[121X statement.[133X4041[33X[0;0Y(There may be local entity definitions inside the [10XDOCTYPE[110X statement, see42SubsectionΒ [14X2.2-3[114X below.)[133X434445[1X2.1-2 [33X[0;0YComments[133X[101X4647[33X[0;0YA [21Xcomment[121X in XML starts with the character sequence [21X[10X<!--[110X[121X and ends with the48sequence [21X[10X-->[110X[121X. Between these sequences there must not be two adjacent dashes49[21X[10X--[110X[121X.[133X505152[1X2.1-3 [33X[0;0YProcessing Instructions[133X[101X5354[33X[0;0YA [21Xprocessing instruction[121X in XML starts with the character sequence [21X[10X<?[110X[121X55followed by a name ([21X[10Xxml[110X[121X is only allowed at the very beginning of the56document to declare it being an XML document, see [14X2.1-1[114X). After that any57characters may follow, except that the ending sequence [21X[10X?>[110X[121X must not occur58within the processing instruction.[133X5960[33X[0;0YΒ [133X6162[33X[0;0YAnd now we turn to those parts of the document which contribute to its63actual content.[133X646566[1X2.1-4 [33X[0;0YNames in XML and Whitespace[133X[101X6768[33X[0;0YA [21Xname[121X in XML (used for element and attribute identifiers, see below) must69start with a letter (in the encoding of the document) or with a colon [21X[10X:[110X[121X or70underscore [21X[10X_[110X[121X character. The following characters may also be digits, dots [21X[10X.[110X[121X71or dashes [21X[10X-[110X[121X.[133X7273[33X[0;0YThis is a simplified description of the rules in the standard, which are74concerned with lots of unicode ranges to specify what a [21Xletter[121X is.[133X7576[33X[0;0YSequences only consisting of the following characters are considered as77[13Xwhitespace[113X: blanks, tabs, carriage return characters and new line78characters.[133X798081[1X2.1-5 [33X[0;0YElements[133X[101X8283[33X[0;0YThe actual content of an XML document consists of [21Xelements[121X. An element has84some [21Xcontent[121X with a leading [21Xstart tag[121X ([14X2.1-6[114X) and a trailing [21Xend tag[121X85([14X2.1-7[114X). The content can contain further elements but they must be properly86nested. One can define elements whose content is always empty, those87elements can also be entered with a single combined tag ([14X2.1-8[114X).[133X888990[1X2.1-6 [33X[0;0YStart Tags[133X[101X9192[33X[0;0YA [21Xstart-tag[121X consists of a less-than-character [21X[10X<[110X[121X directly followed (without93whitespace) by an element name (seeΒ [14X2.1-4[114X), optional attributes, optional94whitespace, and a greater-than-character [21X[10X>[110X[121X.[133X9596[33X[0;0YAn [21Xattribute[121X consists of some whitespace and then its name followed by an97equal sign [21X[10X=[110X[121X which is optionally enclosed by whitespace, and the attribute98value, which is enclosed either in single or double quotes. The attribute99value may not contain the type of quote used as a delimiter or the character100[21X[10X<[110X[121X, the character [21X[10X&[110X[121X may only appear to start an entity, seeΒ [14X2.1-9[114X. We101describe inΒ [14X2.1-11[114X how to enter special characters in attribute values.[133X102103[33X[0;0YNote especially that no whitespace is allowed between the starting [21X[10X<[110X[121X104character and the element name. The quotes around an attribute value cannot105be omitted. The names of elements and attributes are [13Xcase sensitive[113X.[133X106107108[1X2.1-7 [33X[0;0YEnd Tags[133X[101X109110[33X[0;0YAn [21Xend tag[121X consists of the two characters [21X[10X</[110X[121X directly followed by the111element name, optional whitespace and a greater-than-character [21X[10X>[110X[121X.[133X112113114[1X2.1-8 [33X[0;0YCombined Tags for Empty Elements[133X[101X115116[33X[0;0YElements which always have empty content can be written with a single tag.117This looks like a start tag (seeΒ [14X2.1-6[114X) [13Xexcept[113X that the trailing118greater-than-character [21X[10X>[110X[121X is substituted by the two character sequence [21X[10X/>[110X[121X.[133X119120121[1X2.1-9 [33X[0;0YEntities[133X[101X122123[33X[0;0YAn [21Xentity[121X in XML is a macro for some substitution text. There are two types124of entities.[133X125126[33X[0;0YA [21Xcharacter entity[121X can be used to specify characters in the encoding of the127document (can be useful for entering non-ASCII characters which you cannot128manage to type in directly). They are entered with a sequence [21X[10X&#[110X[121X, directly129followed by either some decimal digits or an [21X[10Xx[110X[121X and some hexadecimal digits,130directly followed by a semicolon [21X[10X;[110X[121X. Using such a character entity is just131equivalent to typing the corresponding character directly.[133X132133[33X[0;0YThen there are references to [21Xnamed entities[121X. They are entered with an134ampersand character [21X[10X&[110X[121X directly followed by a name which is directly followed135by a semicolon [21X[10X;[110X[121X. Such entities must be declared somewhere by giving a136substitution text. This text is included in the document and the document is137parsed again afterwards. The exact rules are a bit subtle but you probably138want to use this only in simple cases. Predefined entities for [5XGAPDoc[105X are139described in [14X2.1-10[114X and [14X2.2-3[114X.[133X140141142[1X2.1-10 [33X[0;0YSpecial Characters in XML[133X[101X143144[33X[0;0YWe have seen that the less-than-character [21X[10X<[110X[121X and the ampersand character [21X[10X&[110X[121X145start a tag or entity reference in XML. To get these characters into the146document text one has to use entity references, namely [21X[10X<[110X[121X to get [21X[10X<[110X[121X and147[21X[10X&[110X[121X to get [21X[10X&[110X[121X. Furthermore [21X[10X>[110X[121X must be used to get [21X[10X>[110X[121X when the string [21X[10X]]>[110X[121X148appears in element content (and not as delimiter of a [10XCDATA[110X section149explained below).[133X150151[33X[0;0YAnother possibility is to use a [10XCDATA[110X statement explained inΒ [14X2.1-12[114X.[133X152153154[1X2.1-11 [33X[0;0YRules for Attribute Values[133X[101X155156[33X[0;0YAttribute values can contain entities which are substituted recursively. But157except for the entities < or a character entity it is not allowed that a158< character is introduced by the substitution (there is no XML parsing for159evaluating the attribute value, just entity substitutions).[133X160161162[1X2.1-12 [33X[0;0Y[10XCDATA[110X[101X[1X[133X[101X163164[33X[0;0YPieces of text which contain many characters which can be misinterpreted as165markup can be enclosed by the character sequences [21X[10X<![CDATA[[110X[121X and [21X[10X]]>[110X[121X.166Everything between these sequences is considered as content of the document167and is not further interpreted as XML text. All the rules explained so far168in this section do [13Xnot apply[113X to such a part of the document. The only169document content which cannot be entered directly inside a [10XCDATA[110X statement170is the sequence [21X[10X]]>[110X[121X. This can be entered as [21X[10X]]>[110X[121X outside the [10XCDATA[110X171statement.[133X172173[4X[32X Example [32X[104X174[4X[28XA nesting of tags like <a> <b> </a> </b> is not allowed.[128X[104X175[4X[32X[104X176177178[1X2.1-13 [33X[0;0YEncoding of an XML Document[133X[101X179180[33X[0;0YWe suggest to use the UTF-8 encoding for writing [5XGAPDoc[105X XML documents. But181the tools described in Chapter [14X5[114X also work with ASCII or the various182ISO-8859-X encodings (ISO-8859-1 is also called latin1 and covers most183special characters for western European languages).[133X184185186[1X2.1-14 [33X[0;0YWell Formed and Valid XML Documents[133X[101X187188[33X[0;0YWe want to mention two further important words which are often used in the189context of XML documents. A piece of text becomes a [21Xwell formed[121X XML document190if all the formal rules described in this section are fulfilled.[133X191192[33X[0;0YBut this says nothing about the content of the document. To give this193content a meaning one needs a declaration of the element and corresponding194attribute names as well as of named entities which are allowed. Furthermore195there may be restrictions how such elements can be nested. This [13Xdefinition196of an XML based markup language[113X is done in a [21Xdocument type definition[121X. An197XML document which contains only elements and entities declared in such a198document type definition and obeys the rules given there is called [21Xvalid199(with respect to this document type definition)[121X.[133X200201[33X[0;0YThe main file of the [5XGAPDoc[105X package is [11Xgapdoc.dtd[111X. This contains such a202definition of a markup language. We are not going to explain the formal203syntax rules for document type definitions in this section. But in ChapterΒ [14X3[114X204we will explain enough about it to understand the file [11Xgapdoc.dtd[111X and so the205markup language defined there.[133X206207208[1X2.2 [33X[0;0YEntering [5XGAPDoc[105X[101X[1X Documents[133X[101X209210[33X[0;0YHere are some additional rules for writing [5XGAPDoc[105X XML documents.[133X211212213[1X2.2-1 [33X[0;0YOther special characters[133X[101X214215[33X[0;0YAs [5XGAPDoc[105X documents are used to produce LaTeX and HTML documents, the216question arises how to deal with characters with a special meaning for other217applications (for example [21X[10X&[110X[121X, [21X[10X#[110X[121X, [21X[10X$[110X[121X, [21X[10X%[110X[121X, [21X[10X~[110X[121X, [21X[10X\[110X[121X, [21X[10X{[110X[121X, [21X[10X}[110X[121X, [21X[10X_[110X[121X, [21X[10X^[110X[121X, [21X[10XΒ [110X[121X (this is a218non-breakable space, [21X[10X~[110X[121X in LaTeX) have a special meaning for LaTeX and [21X[10X&[110X[121X, [21X[10X<[110X[121X,219[21X[10X>[110X[121X have a special meaning for HTML (and XML). In [5XGAPDoc[105X you can usually just220type these characters directly, it is the task of the converter programs221which translate to some output format to take care of such special222characters. The exceptions to this simple rule are:[133X223224[30X [33X[0;6Y& and < must be entered as [10X&[110X and [10X<[110X as explained in [14X2.1-10[114X.[133X225226[30X [33X[0;6YThe content of the [5XGAPDoc[105X elements [10X<M>[110X, [10X<Math>[110X and [10X<Display>[110X is LaTeX227code, see [14X3.8[114X.[133X228229[30X [33X[0;6YThe content of an [10X<Alt>[110X element with [10XOnly[110X attribute contains code for230the specified output type, see [14X3.9-1[114X.[133X231232[33X[0;0YRemark: In former versions of [5XGAPDoc[105X one had to use particular entities for233all the special characters mentioned above ([10X&tamp;[110X, [10X&hash;[110X, [10X$[110X,234[10X&percent;[110X, [10X˜[110X, [10X&bslash;[110X, [10X&obrace;[110X, [10X&cbrace;[110X, [10X&uscore;[110X, [10X&circum;[110X, [10X&tlt;[110X,235[10X&tgt;[110X). These are no longer needed, but they are still defined for backwards236compatibility with older [5XGAPDoc[105X documents.[133X237238239[1X2.2-2 [33X[0;0YMathematical Formulae[133X[101X240241[33X[0;0YMathematical formulae in [5XGAPDoc[105X are typed as in LaTeX. They must be the242content of one of three types of [5XGAPDoc[105X elements concerned with mathematical243formulae: [21X[10XMath[110X[121X, [21X[10XDisplay[110X[121X, and [21X[10XM[110X[121X (see SectionsΒ [14X3.8-1[114X andΒ [14X3.8-2[114X for more244details). The first two correspond to LaTeX's math mode and display math245mode. The last one is a special form of the [21X[10XMath[110X[121X element type, that imposes246certain restrictions on the content. On the other hand the content of an [21X[10XM[110X[121X247element is processed in a well defined way for text terminal or HTML output.248The [21X[10XDisplay[110X[121X element also has an attribute such that its content is processed249as in [21X[10XM[110X[121X elements.[133X250251[33X[0;0YNote that the content of these element is LaTeX code, but the special252characters [21X[10X<[110X[121X and [21X[10X&[110X[121X for XML must be entered via the entities described253inΒ [14X2.1-10[114X or by using a [10XCDATA[110X statement, seeΒ [14X2.1-12[114X.[133X254255256[1X2.2-3 [33X[0;0YMore Entities[133X[101X257258[33X[0;0YIn [5XGAPDoc[105X there are some more predefined entities:[133X259260βββββββββββββββ¬ββββββββββ261β [10X&GAP;[110X β [5XGAP[105X β262βββββββββββββββΌββββββββββ€263β [10X&GAPDoc;[110X β [5XGAPDoc[105X β264βββββββββββββββΌββββββββββ€265β [10X&TeX;[110X β TeX β266βββββββββββββββΌββββββββββ€267β [10X&LaTeX;[110X β LaTeX β268βββββββββββββββΌββββββββββ€269β [10X&BibTeX;[110X β BibTeX β270βββββββββββββββΌββββββββββ€271β [10X&MeatAxe;[110X β [5XMeatAxe[105X β272βββββββββββββββΌββββββββββ€273β [10X&XGAP;[110X β [5XXGAP[105X β274βββββββββββββββΌββββββββββ€275β [10X©right;[110X β Β© β276βββββββββββββββΌββββββββββ€277β [10X [110X β [21XΒ [121X β278βββββββββββββββΌββββββββββ€279β [10X–[110X β β β280βββββββββββββββ΄ββββββββββ281282[1XTable:[101X Predefined Entities in the [5XGAPDoc[105X system283284285[33X[0;0YHere [10X [110X is a non-breakable space character.[133X286287[33X[0;0YAdditional entities are defined for some mathematical symbols, see [14X3.8[114X for288more details.[133X289290[33X[0;0YOne can define further local entities right inside the head (seeΒ [14X2.1-1[114X) of a291[5XGAPDoc[105X XML document as in the following example.[133X292293[4X[32X Example [32X[104X294[4X[28X<?xml version="1.0" encoding="UTF-8"?>[128X[104X295[4X[28X[128X[104X296[4X[28X<!DOCTYPE Book SYSTEM "gapdoc.dtd"[128X[104X297[4X[28X [ <!ENTITY MyEntity "some longish <E>text</E> possibly with markup">[128X[104X298[4X[28X ]>[128X[104X299[4X[32X[104X300301[33X[0;0YThese additional definitions go into the [10X<!DOCTYPE[110X tag in square brackets.302Such new entities are used like this: [10X&MyEntity;[110X[133X303304305306