home *** CD-ROM | disk | FTP | other *** search
/ XML Bible (2nd Edition) / XML_Bible_Second_Edition_Hungry_Minds_2001.iso / mac / specs / XML-MathML-20010221 / xml / validation-grammar.xml < prev   
Text File  |  2001-01-04  |  11KB  |  255 lines

  1. <div1 id="cmvg" role="appendixb"><head>Content Markup Validation Grammar</head>
  2. <!-- $Id: validation-grammar.xml,v 1.10 2001/01/04 13:42:46 davidc Exp $ -->
  3.  
  4. <eg><![CDATA[
  5. Informal EBNF grammar for Content Markup structure validation
  6. =============================================================
  7. // Notes
  8. //
  9. // This defines the valid expression trees in content markup
  10. //
  11. // ** it does not define attribute validation -
  12. // ** this has to be done on top
  13. //
  14. // Presentation_tags is a placeholder for a valid
  15. // presentation element start tag or end tag
  16. //
  17. // #PCDATA is the XML parsed character data
  18. //
  19. // symbols beginning with '_' for example _mmlarg are internal symbols
  20. // (recursive grammar usually required for recognition)
  21. //
  22. // all-lowercase symbols for example 'ci' are terminal symbols
  23. // representing MathML content elements
  24. //
  25. // symbols beginning with Uppercase are terminals
  26. // representating other tokens
  27. //
  28. // revised sb 3.nov.97, 16.nov.97 and 22.dec.1997
  29. // revised sb 6.jan.98, 6.Feb.1998 and 4.april.1998
  30. // revised sb 27.nov.2000 for MathML2.0
  31. //
  32. // whitespace  definitions  including presentation_tags
  33. Presentation_tags ::= "presentation"        //placeholder
  34. Space    ::= #x09 | #xoA | #xoD | #x20      //tab, lf, cr, space characters
  35. S        ::= (Space | Presentation_tags)*   //treat presentation as space
  36. // only for content validation
  37. // characters
  38. Char     ::= Space | [#x21 - #xFFFD] 
  39.              | [#x00010000 - #x7FFFFFFFF]   //valid XML chars
  40. // start and end tag functions
  41. // start(\%x) returns a valid start tag for the element \%x
  42. // end(\%x) returns a valid end tag for the element \%x
  43. // empty(\%x) returns a valid empty tag for the element \%x
  44. //
  45. // start(ci)    ::= "<ci>"
  46. // end(cn)      ::= "</cn>"
  47. // empty(plus)  ::= "<plus/>"
  48. //
  49. // The reason for doing this is to avoid writing a grammar
  50. // for all the attributes. The model below is not complete
  51. // for all possible attribute values.
  52.  
  53. _start(\%x)   ::= "<\%x" (Char - '>')* ">"    // returns a valid start tag for the element \%x
  54. _end(\%x)     ::= "<\%x" Space* ">"           // returns a valid end tag for the element \%x
  55. _empty(\%x)   ::= "<\%x" (Char - '>')* "/>"   // returns a valid empty tag for the element \%x
  56. _sg(\%x)      ::= S _start(\%x)               // start tag preceded by optional whitespace
  57. _eg(\%x)      ::= _end(\%x) S                 // end tag followed by optional whitespace
  58. _ey(\%x)      ::= S _empty(\%x) S      // empty tag preceded and followed by optional whitespace
  59.  
  60. // mathml content constructs
  61. _mmlall         ::= _container | _relation | _operator | _qualifier | _other
  62. _mmlarg         ::= _container 
  63. _container      ::= _token | _special | _constructor
  64. _token          ::= ci | cn | csymbol | _constantsym
  65. _special        ::= apply | lambda | reln | fn
  66. _constructor    ::= interval | list | matrix | matrixrow | set | vector    | piecewise
  67.                      | piece | otherwise
  68. _other          ::= condition |  declare | sep
  69. _qualifier      ::= lowlimit | uplimit | bvar | degree | logbase | domainofapplication
  70.                      | momentabout
  71. _constantsym    ::= integers | rationals | reals | naturalnumbers | complexes | primes 
  72.                      | exponentiale | imaginaryi | notanumber | true | false | pi
  73.                      | eulergamma | infinity
  74.  
  75. // relations
  76. _relation       ::= _genrel | _setrel | _seqrel2ary
  77. _genrel         ::= _genrel2ary | _genrelnary
  78. _genrel2ary     ::= ne
  79. _genrelnary     ::= eq | leq | lt | geq | gt
  80. _setrel         ::=  _seqrel2ary | _setrelnary
  81. _setrel2ary     ::=  in | notin | notsubset | notprsubset
  82. _setrelnary     ::= subset | prsubset
  83. _seqrel2ary     ::= tendsto
  84.  
  85. //operators
  86. _operator       ::= _funcop | _sepop | _arithop | _calcop | _vcalcop
  87.                 | _seqop | _trigop | _classop | _statop | _lalgop
  88.                 | _logicop | _setop
  89.  
  90. //functional operators
  91. _funcop         ::= _funcop1ary | _funcopnary
  92. _funcop1ary     ::= inverse     | ident | domain | codomain | image
  93. _funcopnary     ::= fn| compose   // general user-defined function is n-ary
  94.  
  95. // arithmetic operators
  96. // (note minus is both 1ary and 2ary)
  97. _arithop        ::= _arithop1ary | _arithop2ary | _arithopnary  | root
  98. _arithop1ary    ::= abs | conjugate | factorial | minus | arg | real | imaginary
  99.                      | floor | ceiling
  100. _arithop2ary    ::= quotient | divide | minus | power | rem
  101. _arithopnary    ::= plus | times | max | min | gcd | lcm
  102.  
  103. // calculus and vector calculus
  104. _calcop         ::= int | diff | partialdiff
  105. _vcalcop        ::= divergence | grad | curl | laplacian
  106.  
  107. // sequences and series
  108. _seqop          ::= sum | product | limit
  109.  
  110. // elementary classical functions and trigonometry
  111.  
  112. _classop        ::= exp | ln | log
  113.  
  114. _trigop         ::= sin | cos | tan | sec | csc | cot | sinh 
  115.                     | cosh | tanh | sech | csch | coth 
  116.                     | arcsin | arccos | arctan
  117.  
  118. // statistics operators
  119. _statop         ::= _statopnary | moment
  120. _statopnary     ::= mean | sdev | variance | median | mode
  121.  
  122. // linear algebra operators
  123. _lalgop         ::= _lalgop1ary |_lalgop2ary | _lalgopnary
  124. _lalgop1ary     ::= determinant | transpose
  125. _lalgop2ary     ::= vectorproduct | scalarproduct | outerproduct
  126. _lalgopnary     ::= selector
  127.  
  128. // logical operators
  129. _logicop        ::= _logicop1ary | _logicopnary | _logicop2ary | _logicopquant
  130. _logicop1ary    ::= not
  131. _logicop2ary    ::= implies    | equivalent | approx | factorof
  132. _logicopnary    ::= and | or | xor
  133. _logicopquant   ::= forall | exists
  134.  
  135. // set theoretic operators
  136. _setop          ::= _setop1ary |_setop2ary | _setopnary
  137. _setop1ary      ::= card
  138. _setop2ary      ::= setdiff
  139. _setopnary      ::= union | intersect | cartesianproduct
  140.  
  141. // operator groups
  142. _unaryop        ::=  _func1ary | _arithop1ary | _trigop | _classop  
  143.                      | _calcop | vcalcop | _logicop1ary    | _lalgop1ary | setop1ary
  144. _binaryop       ::=  _arithop2ary | _setop2ary | _logicop2ary | _lalgop2ary
  145. _naryop         ::=  _arithopnary | _statopnary  | _logicopnary 
  146.                      | _lalgopnary | _setopnary | _funcopnary
  147. _ispop          ::= int | sum | product
  148. _diffop         ::= diff | partialdiff
  149. _binaryrel      ::= _genrel2ary | _setrel2ary |  _seqrel2ary
  150. _naryrel        ::= _genrelnary | _setrelnary
  151.  
  152. //separator
  153. sep             ::=  _ey(sep)
  154.  
  155. // leaf tokens  and data content of leaf elements
  156. // note _mdata includes Presentation constructs here.
  157. _mdatai         ::= (#PCDATA | Presentation_tags)*
  158. _mdatan         ::= (#PCDATA | sep | Presentation_tags)*
  159. ci              ::=  _sg(ci) _mdatai _eg(ci)
  160. cn              ::=  _sg(cn) _mdatan _eg(cn)
  161. csymbol         ::=  _sg(csymbol) _mdatai _eg(csymbol)
  162.  
  163. // condition -  constraints constraints. contains either
  164. // a single reln (relation), or
  165. // an apply holding a logical combination of relations, or
  166. // a set (over which the operator should be applied)
  167. condition       ::= _sg(condition)  reln | apply | set  _eg(condition)
  168.  
  169. // domains for integral, sum , product
  170. _ispdomain      ::= (lowlimit  uplimit?)
  171.                 | uplimit
  172.                 | interval
  173.                 | condition
  174.  
  175. // apply construct
  176. // Note that apply is used in place of the deprecated reln in MathML2.0
  177. //     for relational operators as well as arithmetic, algebraic etc.
  178. //
  179. apply           ::= _sg(apply) _applybody | _relnbody _eg(apply)
  180. _applybody      ::= 
  181.       ( _unaryop _mmlarg  )                   //1-ary ops
  182.     | (_binaryop _mmlarg _mmlarg)             //2-ary ops
  183.     | (_naryop _mmlarg*)                      //n-ary ops, enumerated arguments
  184.     | (_naryop bvar* condition _mmlarg)       //n-ary ops, condition defines argument list
  185.     | (_ispop  bvar? _ispdomain? _mmlarg)     //integral, sum, product
  186.     | (_ispop  domainofapplication? _mmlarg)  //integral, sum, product
  187.     | (_diffop bvar* _mmlarg)                 //differential ops
  188.     | (log logbase? _mmlarg)                  //logs
  189.     | (moment degree? momentabout? _mmlarg*)           //statistical moment
  190.     | (root degree? _mmlarg)                           //radicals - default is square-root
  191.     | (limit bvar* lowlimit? condition? _mmlarg)       //limits
  192.     | (_logicopquant bvar+ condition? (reln | apply))  //quantifier with explicit bound variables
  193.  
  194.  
  195.  
  196. // equations and relations - reln uses lisp-like syntax (like apply)
  197. // the bvar and condition are used to construct a "such that" or
  198. // "where" constraint on the relation  . 
  199. // Note that reln is deprecated but still valid in MathML2.0
  200. reln            ::= _sg(reln) _relnbody _eg(reln)
  201. _relnbody       ::= ( _binaryrel bvar* condition? _mmlarg _mmlarg )
  202.                     | ( _naryrel bvar* condition? _mmlarg*  )
  203.  
  204. // fn construct
  205. // Note that fn is deprecated but still valid in MathML2.0
  206. fn                      ::= _sg(fn) _fnbody _eg(fn)
  207. _fnbody         ::=  Presentation_tags | container 
  208.  
  209. // lambda construct     - note at least 1 bvar must be present
  210. lambda          ::=  _sg(lambda) _lambdabody _eg(lambda)
  211. _lambdabody     ::=  bvar+ _container  //multivariate lambda calculus
  212.  
  213. //declare construct
  214. declare         ::= _sg(declare) _declarebody _eg(declare)
  215. _declarebody    ::= ci (fn | constructor)?
  216.  
  217. // constructors
  218. interval    ::=  _sg(interval) _mmlarg _mmlarg _eg(interval)    //start, end define interval
  219. set         ::=  _sg(set) _lsbody _eg(set)
  220. list        ::=  _sg(list) _lsbody _eg(list)
  221. _lsbody     ::=  _mmlarg*                  //enumerated arguments
  222.              | (bvar* condition _mmlarg)   //condition constructs arguments
  223.  
  224. matrix        ::= _sg(matrix) matrixrow* _eg(matrix)
  225. matrixrow     ::= _sg(matrixrow) _mmlall* _eg(matrixrow)         //allows matrix of operators
  226.  
  227. vector        ::= _sg(vector) _mmlarg* _eg(vector)
  228.  
  229. piecewise     ::= _sg(piecewise) piece* otherwise? _eg(piecewise)
  230. piece         ::= _sg(piece) _mmlall _eg(piece)          //allows piecewise construct of operators
  231. otherwise     ::= _sg(otherwise) _mmlall _eg(otherwise)  //allows piecewise construct of operators
  232.  
  233. //qualifiers - note the contained _mmlarg could be a reln
  234. lowlimit            ::= _sg(lowlimit) _mmlarg  _eg(lowlimit)
  235. uplimit             ::= _sg(uplimit) _mmlarg _eg(uplimit)
  236. bvar                ::= _sg(bvar) ci degree? _eg(bvar)
  237. degree              ::= _sg(degree) _mmlarg _eg(degree)
  238. logbase             ::= _sg(logbase) _mmlarg _eg(logbase)
  239. domainofapplication ::= _sg(domainofapplication) _mmlarg _eg(domainofapplication)
  240. momentabout         ::= _sg(momentabout) _mmlarg _eg(momentabout)
  241.  
  242. //relations and operators and constant symbols
  243. // (one declaration for each operator and relation element)
  244. _relation       ::= _ey(\%relation)         //for example <eq/>  <lt/>
  245. _operator       ::= _ey(\%operator)         //for example <exp/> <times/>
  246. _const-symbol   ::= _ey(\%const-symbol)     //for example <integers/> <false/>
  247.  
  248. //the top level math element
  249. //allow declare only at the head of a math element.
  250. math            ::= _sg(math) declare* mmlall* _eg(math)
  251.  
  252. ]]></eg>
  253.  
  254. </div1>
  255.