summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/stex/schema/rnc/omdoc+ltxml.rnc
blob: 2061641178741fa2a32fde028df0195b4ba26ce1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#   A RelaxNG for Open Mathematical documents (OMDoc 1.2) with LaTeXML
# $Id: omdoc+ltxml.rnc 1884 2011-09-09 12:45:49Z kohlhase $
# $HeadURL: https://svn.kwarc.info/repos/stex/trunk/schema/rnc/omdoc+ltxml.rnc $
#   See the documentation and examples at http://omdoc.org
#   (c) 2010 Michael Kohlhase, released under the GNU Public License (GPL)

default namespace omdoc = "http://omdoc.org/ns"

## we include the OMDoc Schema, but we allow the sectioning elements defined below
## as document structuring elements as well. 
include "omdoc/omdoc.rnc" {docstruct.class = omgroup* & lechapter*}

## we extend the Math Objects by the ones introduced by LaTeXML
mobj |= grammar {
    include "LaTeXML/LaTeXML-common.rnc"
    include "LaTeXML/LaTeXML-math.rnc" 
    start = Math}

## we extend the model of rendering elements by XMath, and we extend the XMath there, so
## that we can cope with piecewise and friends at the intermediate level. 
render.class |= grammar {
    include "LaTeXML/LaTeXML.rnc"
   {#XMath.class &= XMRow* & XMCell*
#    XMRow_model &= element XMTok {attribute role {xsd:string {pattern = "ID"}}}
#    XMArray_model &= element XMTok {attribute role {xsd:string {pattern = "ID"}}}
    XMTok_attributes &= parent ntn.attrib
    start = Math | \text}}

## we extend the core structural classes of OMDoc with various LaTeXML counterparts. These
## are usful, since sTeX defers to LaTeXML to generate these, and in a later pass (the
## XSLTs) replaces them by their OMDoc counterparts. The rules below, have another
## purpose: in the OMDoc schema (which is the primary one here, we use the & operator for
## making classes, whereas the LaTeXML schema uses the less flexible | operator. Therefore
## we need to construct conjunctive extensions in start macro. 

inline.class &=  grammar {
    include "LaTeXML/LaTeXML.rnc" 
         {Common.attributes &=parent id.attribs
	  Inline.class = parent inline.class
	  text_model = parent inline.model
	  start=bibref* & break* & ref* & cite* & \text* & emph*}}

plike.class  &=  grammar {
    include "LaTeXML/LaTeXML.rnc" 
         {Common.attributes =parent id.attribs
	  Inline.class = parent inline.class
	  Block.class = parent plike.class
#	  Flow.class = parent flow.class
	  text_model = parent inline.model
	  listingblock_model = parent plike.class
	  start = p* & tabular* & 
	            equation* & equationgroup* & 
		    figure* & graphics* & verbatim* & listingblock* & listing* & 
		    itemize* & enumerate* & description*}}


tikz = element tikz {text}	

## we allow various LaTeXML elements as a top-level elements, 
## they will be converted by XSLT later
omdoc.class &=  grammar {include "LaTeXML/LaTeXML.rnc" {
	    Common.attributes &=parent id.attribs
	    Inline.class = parent inline.class
	    Block.class = parent plike.class
	    Para.class = parent omdoc.class 
#	    Flow.class = parent flow.class
	    text_model = parent inline.model
	    listingblock_model = parent plike.class
	    start= para* & figure* & table* & listing* &
                       itemize* & enumerate* & description*}}

backmatter &= grammar {include "LaTeXML/LaTeXML.rnc" {
	    Common.attributes &=parent id.attribs
	    Inline.class = parent inline.class
	    Block.class = parent plike.class
	    Para.class = parent omdoc.class 
#	    Flow.class = parent flow.class
	    text_model = parent inline.model
	    listingblock_model = parent plike.class
	    start= bibliography*}}


## we prepare some nested content models for sectioning elements
lesubparagraph =  subparagraph*
leparagraph =        paragraph*  &  lesubparagraph 
lesubsubsection = subsubsection* & leparagraph
lesubsection =      subsection* & lesubsubsection
lesection =            section* & lesubsection
lechapter =            chapter* & lesection

## they need to be able to nest theories transparently
theory.chapter = element theory {theory.attribs & 
	                                            metadata.class & 
						    omdoc.class  & 
						    constitutive.class & 
						    lesection}
theory.section = element theory {theory.attribs & 
	                                            metadata.class & 
						    omdoc.class &  
						    constitutive.class & 
						    lesubsection}
theory.subsection = element theory {theory.attribs & 
                                                          metadata.class &
							  omdoc.class  & 
							  constitutive.class & 
							  lesubsubsection}
theory.subsubsection = element theory {theory.attribs & 
		                                                metadata.class &  
								omdoc.class & 
								constitutive.class & 
								leparagraph}
theory.paragraph = element theory {theory.attribs & 
		                                        metadata.class &  
							omdoc.class & 
							constitutive.class & 
							lesubparagraph}
theory.subparagraph = element theory {theory.attribs & 
		                                              metadata.class &
							      omdoc.class &
							      constitutive.class}

sectional.attribs = id.attribs

## and now the elemens themselves
chapter = element chapter {sectional.attribs & 
	                                   metadata.class & 
					   omdoc.class  &  
					   theory.chapter*}
section= element section{sectional.attribs & 
	                                 metadata.class  & 
					 omdoc.class &  
					 theory.section*}
subsection= element subsection {sectional.attribs & 
	                                             metadata.class & 
						     omdoc.class & 
						     theory.subsection*}
subsubsection= element subsubsection {sectional.attribs & 
	                                                        metadata.class &  
								omdoc.class & 
								theory.subsubsection*}
paragraph= element paragraph {sectional.attribs & 
                                                  metadata.class & 
						  omdoc.class & 
						  theory.paragraph*}
subparagraph= element subparagraph {sectional.attribs & 
	                                                      metadata.class & 
							      omdoc.class &
							      theory.subparagraph*}