<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE templates SYSTEM "chrome://abacus/content/templates/templates.dtd">
<templates xmlns="http://abacus.mozdev.org/namespaces/MathML-Editor/#templates"
  xmlns:math="http://www.w3.org/1998/Math/MathML"
  xmlns:html="http://www.w3.org/1999/xhtml"
  xmlns:mEdit="http://abacus.mozdev.org/namespaces/MathML-Editor/"
  >
  <contentTemplates>
    <template operationName="plus" indexCode="A">
<!--
* The operationName designates just which kind of operation the content specifies.  
  Usually, it should be the name of the critical element.

* The indexCode designates a letter code (A-Z) for a particular instance of an operation.
  Ideally, there should be only one instance; however, the templates must be prepared for when
  there is a different content template needed altogether.

* Content template elements usually have for their only child a math:apply element.
-->
      <math:apply>
        <math:plus/>
        <mEdit:fitb-set start="0" end="mEdit:control('x')" loopVariable="mEdit:x">
          <mEdit:fitb mEdit:x="mEdit:index"/>
<!--
* mEdit:fitb-set specifies a repeating fragment of markup, basically a for-loop.  Given:
  <mEdit:fitb-set start="0" end="3" loopVariable="x">
    <mEdit:fitb x="foo"/>
    <mEdit:fitb x="bar"/>
  </mEdit:fitb-set>

  the equivalent is:

  <mEdit:fitb foo="0"/>
  <mEdit:fitb bar="1"/>
  <mEdit:fitb foo="2"/>
  <mEdit:fitb bar="3"/>

  Each appearance of the loopVariable attribute will result in the setting of the appropriately named attribute to the
value of the loopVariable, and the increase of said loopVariable by one.

* The mEdit:control(userInterfaceControl) pseudo-function returns an integer from the user.
  This is used when the number of arguments is flexible.
-->
        </mEdit:fitb-set>
      </math:apply>
      <controlList>
        <mEdit:control name="x" min="2"/>
<!--
* The controlList element designates an ordered list of controls corresponding to the mEdit:control pseudo-function.

* Each control is named as an element, with a name attribute identifying the control and a label.

-->
      </controlList>
    </template>
  </contentTemplates>
  <presentationTemplates>
    <template operationName="plus" indexCode="A"
                          xml:lang="en-US" markupLanguage="MathML" alternateIndex="0">
<!--
* The xml:lang attribute, per the appropriate specification, identifies a human language for the presentation markup.

* The markupLanguage attribute identifies an XML markup language this presentation markup signifies.
For instance, a MathML markupLanguage attribute indicates pure MathML:  (1 + 1 + 1)
A XHTML markupLanguage attribute indicates a presentation which is hypertext and probably spelled out as words:
  (1 plus 1 plus 1)

* The alternateIndex attribute, like the indexCode attribute for contentTemplate, designates a unique 
  presentation markup for the other attributes given.

* <presentationTemplate markupLanguage="MathML"> elements usually have a <math:mrow/> element for their first child.

* Other presentationTemplate elements require a first child in the designated namespace.

* The second child element of presentationTemplate elements is a controlList element.

-->
      <math:mrow>
        <mEdit:fitb-set start="0" end="mEdit:control('x') - 1" loopVariable="mEdit:x">
          <mEdit:fitb mEdit:x="mEdit:index"/>
          <math:mo>+</math:mo>
        </mEdit:fitb-set>
        <mEdit:fitb mEdit:index="mEdit:control('x')"/>
      </math:mrow>
      <controlList>
        <mEdit:control name="x" label="Number of arguments"/>
      </controlList>
    </template>
  </presentationTemplates>
  <userInterfaces>
    <uiGroups xml:lang="en-US">
      <uiGroup label="Comparisons &amp; Operations" shortLabel="Basics">
        <uiControl operationName="plus" indexCode="A"
                   label="Addition (+)" imgsrc="chrome://abacus/skin/icons/en-US/plus.gif"/>
<!--
* The userInterfaces element designates the organization of generic user-interface controls.

* The uiGroups element designates a language which the user should receive the user-interface controls in.

* The uiGroup element specifies a grouping of user-interface controls by a common category.

* The uiControl element specifies a specific control.  The operationName and indexCode, again, identify a 
  contentTemplate element and its corresponding presentationTemplate elements.

* The label and shortLabel attribute give text identifiers for each control.

* The imgsrc attribute, if provided, gives an optional image for use as an icon.

* These user-interface elements are not in the XUL namespace for one reason.  The application using them may wish to
display them as a <xul:menubar/>, a set of <xul:listmenu/> elements, floating grids of <xul:button/> elements, etc.
-->

      </uiGroup>
    </uiGroups>
  </userInterfaces>

</templates>

<!-- Recap:  A templates file should look something like this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE templates SYSTEM "chrome://abacus/content/templates/templates.dtd">
<templates xmlns="http://abacus.mozdev.org/namespaces/MathML-Editor/#templates"
  xmlns:math="http://www.w3.org/1998/Math/MathML"
  xmlns:html="http://www.w3.org/1999/xhtml"
  xmlns:mEdit="http://abacus.mozdev.org/namespaces/MathML-Editor/"
  >
  <contentTemplates>
    <template operationName="plus" indexCode="A">
      <math:apply>
        <math:plus/>
        <mEdit:fitb-set start="0" end="mEdit:control('x')" loopVariable="mEdit:x">
          <mEdit:fitb mEdit:x="mEdit:index"/>
        </mEdit:fitb-set>
      </math:apply>
      <controlList>
        <control name="x" min="2"/>
      </controlList>
    </template>
  </contentTemplates>
  <presentationTemplates>
    <template operationName="plus" indexCode="A"
                          xml:lang="en-US" markupLanguage="MathML" alternateIndex="0">
      <math:mrow>
        <mEdit:fitb-set start="0" end="mEdit:control('x') - 1" loopVariable="mEdit:x">
          <mEdit:fitb mEdit:x="mEdit:index"/>
          <math:mo>+</math:mo>
        </mEdit:fitb-set>
        <mEdit:fitb mEdit:index="mEdit:control('x')"/>
      </math:mrow>
      <controlList>
        <mEdit:control name="x" label="Number of arguments"/>
      </controlList>
    </template>
  </presentationTemplates>
  <userInterfaces>
    <uiGroups xml:lang="en-US">
      <uiGroup label="Comparisons &amp; Operations" shortLabel="Basics">
        <uiControl operationName="plus" indexCode="A"
                   label="Addition (+)" imgsrc="chrome://abacus/skin/icons/en-US/plus.gif"/>
      </uiGroup>
    </uiGroups>
  </userInterfaces>
</templates>

-->