1# /=====================================================================\
2# |  LaTeXML-math.rnc                                                   |
3# | RelaxNG model for LaTeXML generated documents                       |
4# |=====================================================================|
5# | Part of LaTeXML:                                                    |
6# |  Public domain software, produced as part of work done by the       |
7# |  United States Government & not subject to copyright in the US.     |
8# |=====================================================================|
9# | Bruce Miller <bruce.miller@nist.gov>                        #_#     |
10# | http://dlmf.nist.gov/LaTeXML/                              (o o)    |
11# \=========================================================ooo==U==ooo=/
12
13default namespace = "http://dlmf.nist.gov/LaTeXML"
14
15## The math module defines LaTeXML's internal representation of mathematical
16## content, including the basic math container \elementref{Math}.  This element is
17## considered inline, as it will be contained within some other block-level
18## element, eg. \elementref{equation} for display-math.
19Inline.class |= Math
20
21## This class defines the content of the \elementref{Math} element.
22## Additionally, it could contain MathML or OpenMath, after postprocessing.
23Math.class   = XMath
24
25## These elements comprise the internal math representation, being
26## the content of the \elementref{XMath} element.
27XMath.class =
28    XMApp  | XMTok  | XMRef  | XMHint | XMArg
29  | XMWrap | XMDual | XMText | XMArray | ERROR
30
31#======================================================================
32
33Math =
34## Outer container for all math. This holds the internal
35## \elementref{XMath} representation, as well as image data and other representations.
36element Math { Math_attributes, Math_model }
37
38## Attributes for \elementref{Math}.
39Math_attributes =
40  Common.attributes,
41  Imageable.attributes,
42  ID.attributes,
43  Backgroundable.attributes,
44
45  ## display or inline mode.
46  attribute mode { "display" | "inline" }?,
47
48  ## reconstruction of the \TeX\ that generated the math.
49  attribute tex { text }?,
50
51  ## more semantic version of \attr{tex}.
52  attribute content-tex { text }?,
53
54  ## a textified representation of the math.
55  attribute text { text }?,
56
57  ## preserved grammar-near lexemes for export to external apps
58  attribute lexemes { text }?
59
60## Content model for \elementref{Math}.
61Math_model =   Math.class*
62
63#======================================================================
64## Common attributes for the various XMath elements.
65XMath.attributes =
66  Positionable.attributes,
67
68  ## The role that this item plays in the Grammar.
69  attribute role { text }?,
70
71  ## an enclose style to enclose the object
72  ## with legitimate values being those of MathML's menclose notations;
73  attribute enclose { text }?,
74
75  ## left, or leading, (presumably non-semantic) padding space.
76  attribute lpadding { text }?,
77
78  ## right, or trailing, (presumably non-semantic) padding space.
79  attribute rpadding { text }?,
80
81  ## The name of the token, typically the control sequence that created it.
82  attribute name { text }?,
83
84  ## A more semantic name corresponding to the intended meaning,
85  ## such as the OpenMath name.
86  attribute meaning { text }?,
87
88  ## The OpenMath CD for which \attr{meaning} is a symbol.
89  attribute omcd { text }?,
90
91  ## An encoding of the position of sub/superscripts
92  ## Before parsing, it takes two forms. On a base token or element,
93  ## it is one of (pre|mid|post), indicating where any script can be placed.
94  ## On a script token, it is an integer level.
95  ## After parsing, the concatenation is moved to the sub|super-script "operator".
96  attribute scriptpos { text }?,
97
98  ## an annotation placed by the parser when it suspects this token may be used as a function.
99  attribute possibleFunction { text }?,
100
101  ## an id to where the declaration of this object is given,
102  ## preferably the xml:id of an ltx:declare
103  attribute decl_id { text }?,
104
105  ## reference to an arbitrary url.
106  attribute href { text }?
107
108#======================================================================
109
110XMath =
111## Internal representation of mathematics.
112element XMath { XMath_attributes, XMath_model }
113
114## Attributes for \elementref{XMath}.
115XMath_attributes = Common.attributes, ID.attributes
116
117## Content model for \elementref{XMath}.
118XMath_model = XMath.class*
119
120#======================================================================
121
122XMTok =
123## General mathematical token.
124element XMTok { XMTok_attributes, XMTok_model }
125
126## Attributes for \elementref{XMTok}.
127XMTok_attributes =
128  Common.attributes,
129  XMath.attributes,
130  ID.attributes,
131  Fontable.attributes,
132  Colorable.attributes,
133  Backgroundable.attributes,
134
135  ## A thickness used for drawing any lines which are part of presenting the token,
136  ## such as the fraction line for the fraction operator.
137  attribute thickness { text }?,
138
139  ## Whether or not the symbol should be stretchy.
140  ## This shares MathML's ambiguity about horizontal versus vertical stretchiness.
141  ## When not set, defaults to whatever MathML's operator dictionary says.
142  attribute stretchy { xsd:boolean }?,
143
144  ## The math style used for displaying the application of this token
145  ## when it represents some sort of fraction, variable-sized operator or stack of expressions
146  ## (note that this applies to binomials or other stacks of expressions as well as fractions).
147  ## Values of \texttt{display} or \texttt{text} correspond to \TeX's
148  ## displaystyle or textstyle, while \texttt{inline} indicates the
149  ## stack should be arranged horizontally (the layout may depend on the operator).
150  attribute mathstyle { ( "display" | "text" | "script" | "scriptscript") }?
151
152## Content model for \elementref{XMTok}.
153XMTok_model = text*
154
155#======================================================================
156
157XMApp =
158## Generalized application of a function, operator, whatever (the first child)
159## to arguments (the remaining children).
160## The attributes are a subset of those for \elementref{XMTok}.
161element XMApp { XMApp_attributes, XMApp_model }
162
163## Attributes for \elementref{XMApp}.
164XMApp_attributes =
165  Common.attributes,
166  XMath.attributes,
167  ID.attributes,
168  Colorable.attributes,
169  Backgroundable.attributes
170
171## Content model for \elementref{XMApp}.
172XMApp_model = XMath.class*
173
174#======================================================================
175
176XMDual =
177## Parallel markup of content (first child) and presentation (second child)
178## of a mathematical object.
179## Typically, the arguments are shared between the two branches:
180## they appear in the content branch, with \attr{id}'s,
181## and \elementref{XMRef} is used in the presentation branch
182element XMDual { XMDual_attributes, XMDual_model }
183
184## Attributes for \elementref{XMDual}.
185XMDual_attributes =
186  Common.attributes,
187  XMath.attributes,
188  ID.attributes
189
190## Content model for \elementref{XMDual}.
191XMDual_model = XMath.class, XMath.class
192
193#======================================================================
194
195XMHint =
196## Various layout hints, usually spacing, generally ignored in parsing.
197## The attributes are a subset of those for \elementref{XMTok}.
198element XMHint { XMHint_attributes, XMHint_model }
199
200## Attributes for \elementref{XMHint}.
201XMHint_attributes =
202  Common.attributes,
203  XMath.attributes,
204  ID.attributes
205
206## Content model for \elementref{XMHint}.
207XMHint_model = empty
208
209#======================================================================
210
211XMText =
212## Text appearing within math.
213element XMText { XMText_attributes, XMText_model }
214
215## Attributes for \elementref{XMText}.
216XMText_attributes =
217  Common.attributes,
218  XMath.attributes,
219  Backgroundable.attributes,
220  ID.attributes
221
222## Content model for \elementref{XMText}.
223XMText_model = (text | Inline.class | Misc.class)*
224
225#======================================================================
226
227XMWrap =
228## Wrapper for a sequence of tokens used to assert the role of the
229## contents in its parent. This element generally disappears after parsing.
230## The attributes are a subset of those for \elementref{XMTok}.
231element XMWrap { XMWrap_attributes, XMWrap_model }
232
233## Attributes for \elementref{XMWrap}.
234XMWrap_attributes =
235  Common.attributes,
236  XMath.attributes,
237  Backgroundable.attributes,
238  ID.attributes,
239
240  ## The grammatical rule that should apply to the contained sequence
241  attribute rule { text }?,
242
243  attribute style { text }?
244
245## Content model for \elementref{XMWrap}.
246XMWrap_model = XMath.class*
247
248#======================================================================
249
250XMArg =
251## Wrapper for an argument to a structured macro.
252## It implies that its content can be parsed independently of its parent,
253## and thus generally disappears after parsing.
254element XMArg { XMArg_attributes, XMArg_model }
255
256## Attributes for \elementref{XMArg}.
257XMArg_attributes =
258  Common.attributes,
259  XMath.attributes,
260  ID.attributes,
261
262  ## The grammatical rule that should apply to the contained sequence
263  attribute rule { text }?
264
265## Content model for \elementref{XMArg}.
266XMArg_model = XMath.class*
267
268#======================================================================
269
270XMRef =
271## Structure sharing element typically used in the presentation
272## branch of an \elementref{XMDual} to refer to the arguments present in the content branch.
273element XMRef { XMRef_attributes, XMRef_model }
274
275## Attributes for \elementref{XMRef}.
276XMRef_attributes =
277  Common.attributes,
278  XMath.attributes,
279  ID.attributes,
280  IDREF.attributes
281
282## Content model for \elementref{XMRef}.
283XMRef_model = empty
284
285#======================================================================
286
287XMArray =
288## Math Array/Alignment structure.
289# The attributes are a subset of those for \elementref{XMTok} or of \elementref{tabular}.
290element XMArray { XMArray_attributes, XMArray_model }
291
292## Attributes for \elementref{XMArray}.
293XMArray_attributes =
294  Common.attributes,
295  XMath.attributes,
296  ID.attributes,
297
298  ## the spacing between rows
299  attribute rowsep { Length.type}?,
300
301  ## the spacing between columns
302  attribute colsep { Length.type}?
303
304## Content model for \elementref{XMArray}.
305XMArray_model = XMRow*
306
307#======================================================================
308XMRow =
309## A row in a math alignment.
310element XMRow { XMRow_attributes, XMRow_model }
311
312## Attributes for \elementref{XMRow}.
313XMRow_attributes =
314  Common.attributes,
315  Backgroundable.attributes,
316  ID.attributes
317
318## Content model for \elementref{XMRow}.
319XMRow_model = XMCell*
320
321#======================================================================
322
323XMCell =
324## A cell in a row of a math alignment.
325element XMCell { XMCell_attributes, XMCell_model }
326
327## Attributes for \elementref{XMCell}.
328XMCell_attributes =
329  Common.attributes,
330  Backgroundable.attributes,
331  ID.attributes,
332
333  ## indicates how many columns this cell spans or covers.
334  attribute colspan { xsd:nonNegativeInteger }?,
335
336  ## indicates how many rows this cell spans or covers.
337  attribute rowspan { xsd:nonNegativeInteger }?,
338
339# This would have been clearer, but messes up conversion to dtd
340#  attribute align { "left" | "right" | "center" | "justify" | text }?,
341  ##  specifies the alignment of the content.
342  attribute align { text }?,
343
344  ## specifies the desired width for the column.
345  attribute width { text }?,
346
347  ## records a sequence of t or tt, r or rr, b or bb and l or ll
348  ## for borders or doubled borders on any side of the cell.
349  attribute border { text }?,
350
351  ## whether this cell corresponds to a table row or column heading or both
352  attribute thead { "column" | "column row" | "row"}?
353
354## Content model for \elementref{XMCell}.
355XMCell_model =   XMath.class*
356#======================================================================
357