#     This is the Mathematical Markup Language (MathML) 3.0, an XML
#     application for describing mathematical notation and capturing
#     both its structure and content.
#
#     Copyright 1998-2009 W3C (MIT, ERCIM, Keio)
# 
#     Use and distribution of this code are permitted under the terms
#     W3C Software Notice and License
#     http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231


default namespace m = "http://www.w3.org/1998/Math/MathML"
namespace local = ""

start = math

math = element math {math.attributes,MathExpression*}
MathExpression = semantics

NonMathMLAtt = attribute (* - (local:*|m:*)) {xsd:string} 

CommonDeprecatedAtt = attribute other {text}?

CommonAtt = attribute id {xsd:ID}?,
            attribute xref {text}?,
            attribute class {xsd:NMTOKENS}?,
            attribute style {xsd:string}?,
            attribute href {xsd:anyURI}?,
            CommonDeprecatedAtt,
            NonMathMLAtt*


math.attributes = CommonAtt,
               attribute display {"block" | "inline"}?,
               attribute maxwidth {length}?,
               attribute overflow {"linebreak" | "scroll" | "elide" | "truncate" | "scale"}?,
               attribute altimg {xsd:anyURI}?,
               attribute altimg-width {length}?,
               attribute altimg-height {length}?,
               attribute altimg-valign {length | "top" | "middle" | "bottom"}?,
               attribute alttext {text}?,
               attribute cdgroup {xsd:anyURI}?,
               math.deprecatedattributes

# the mathml3-presentation schema  adds additional attributes
# to the math element, all those valid on mstyle

math.deprecatedattributes = attribute mode {xsd:string}?,
                            attribute macros {xsd:string}?


name = attribute name {xsd:NCName}
cd = attribute cd {xsd:NCName}

src = attribute src {xsd:anyURI}?

annotation = element annotation {annotation.attributes,text}
                     
annotation-xml.model = (MathExpression|anyElement)*

anyElement =  element (* - m:*) {(attribute * {text}|text| anyElement)*}

annotation-xml = element annotation-xml {annotation.attributes,
                                         annotation-xml.model}
annotation.attributes = CommonAtt,
	                cd?,
                        name?,
                        DefEncAtt,
                        src?

DefEncAtt = attribute encoding {xsd:string}?,
            attribute definitionURL {xsd:anyURI}?

semantics = element semantics {semantics.attributes,
                               MathExpression, 
                              (annotation|annotation-xml)*}
semantics.attributes = CommonAtt,DefEncAtt,cd?,name?



length = xsd:string {
  pattern = '\s*((-?[0-9]*(\.[0-9]*)?(e[mx]|in|cm|mm|p[xtc]|%)?)|(negative)?((very){0,2}thi(n|ck)|medium)mathspace)\s*' 
}

