<?xml version="1.0" encoding="UTF-8"?>
<grammar xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
  <start>
    <element name="config">
      <interleave>
        <zeroOrMore>
          <!-- Option scope -->
          <element name="optionscope">
            <attribute name="type">
              <choice>
                <value>GLOBAL</value>
                <value>ENTRYTYPE</value>
                <value>ENTRY</value>
                <value>NAMELIST</value>
                <value>NAME</value>
              </choice>
            </attribute>
            <oneOrMore>
              <element name="option">
                <attribute name="datatype">
                  <choice>
                    <value>boolean</value>
                    <value>integer</value>
                    <value>string</value>
                    <value>xml</value>
                  </choice>
                </attribute>
                <optional>
                  <!--
                    Applies to ENTRY, NAMELIST and NAME scope
                    Only set for meta-options and if defined, what biber should split
                    the option into on reading it
                  -->
                  <attribute name="backendin">
                    <data type="string"/>
                  </attribute>
                </optional>
                <optional>
                  <!--
                    Applies to ENTRY, NAMELIST and NAME scope
                    Determines whether biber will write the option to its ouput (e.g.
                    .bbl) because biblatex needs to know the value.
                  -->
                  <attribute name="backendout">
                    <data type="boolean"/>
                  </attribute>
                </optional>
                <data type="string"/>
              </element>
            </oneOrMore>
          </element>
        </zeroOrMore>
        <optional>
          <element name="clrmacros">
            <choice>
              <value>0</value>
              <value>1</value>
            </choice>
          </element>
        </optional>
        <optional>
          <element name="collate">
            <choice>
              <value>0</value>
              <value>1</value>
            </choice>
          </element>
        </optional>
        <optional>
          <element name="collate_options">
            <oneOrMore>
              <element name="option">
                <interleave>
                  <attribute name="name"/>
                  <attribute name="value"/>
                </interleave>
              </element>
            </oneOrMore>
          </element>
        </optional>
        <zeroOrMore>
          <!-- datafield sets -->
          <element name="datafieldset">
            <attribute name="name"/>
            <oneOrMore>
              <element name="member">
                <choice>
                  <group>
                    <optional>
                      <attribute name="fieldtype">
                        <ref name="dmfieldtype"/>
                      </attribute>
                    </optional>
                    <optional>
                      <attribute name="datatype">
                        <ref name="dmdatatype"/>
                      </attribute>
                    </optional>
                  </group>
                  <optional>
                    <attribute name="field"/>
                  </optional>
                </choice>
                <empty/>
              </element>
            </oneOrMore>
          </element>
        </zeroOrMore>
        <optional>
          <!-- Annotation marker -->
          <element name="annotation_marker">
            <text/>
          </element>
        </optional>
        <optional>
          <!--
            Can't specify the config file location in the config file ...
            element configfile          { text }? & 
          -->
          <element name="convert_control">
            <choice>
              <value>0</value>
              <value>1</value>
            </choice>
          </element>
        </optional>
        <optional>
          <element name="dot_include">
            <text/>
          </element>
        </optional>
        <optional>
          <!-- Data model specification (mainly for tool mode) -->
          <ref name="datamodel"/>
        </optional>
        <optional>
          <element name="decodecharsset">
            <text/>
          </element>
        </optional>
        <optional>
          <element name="debug">
            <choice>
              <value>0</value>
              <value>1</value>
            </choice>
          </element>
        </optional>
        <optional>
          <element name="fastsort">
            <choice>
              <value>0</value>
              <value>1</value>
            </choice>
          </element>
        </optional>
        <optional>
          <element name="fixinits">
            <choice>
              <value>0</value>
              <value>1</value>
            </choice>
          </element>
        </optional>
        <optional>
          <!--
            Would never want this in the config file
             element help                { "0" | "1" }? &
          -->
          <ref name="inheritance"/>
        </optional>
        <optional>
          <element name="input_encoding">
            <text/>
          </element>
        </optional>
        <optional>
          <element name="listsep">
            <text/>
          </element>
        </optional>
        <optional>
          <element name="logfile">
            <text/>
          </element>
        </optional>
        <optional>
          <element name="mincrossrefs">
            <data type="unsignedByte"/>
          </element>
        </optional>
        <optional>
          <element name="mssplit">
            <text/>
          </element>
        </optional>
        <optional>
          <element name="namesep">
            <text/>
          </element>
        </optional>
        <optional>
          <!--
            Can't specify not to use a config file in the config file ...
             element noconf              { "0" | "1" }? &
          -->
          <element name="nodieonerror">
            <choice>
              <value>0</value>
              <value>1</value>
            </choice>
          </element>
        </optional>
        <optional>
          <element name="nolog">
            <choice>
              <value>0</value>
              <value>1</value>
            </choice>
          </element>
        </optional>
        <optional>
          <!-- noinit specification -->
          <element name="noinits">
            <oneOrMore>
              <element name="noinit">
                <attribute name="value">
                  <data type="string"/>
                </attribute>
                <empty/>
              </element>
            </oneOrMore>
          </element>
        </optional>
        <optional>
          <!-- nolabel specification -->
          <element name="nolabels">
            <oneOrMore>
              <element name="nolabel">
                <attribute name="value">
                  <data type="string"/>
                </attribute>
                <empty/>
              </element>
            </oneOrMore>
          </element>
        </optional>
        <optional>
          <!-- nosort specification -->
          <element name="nosort">
            <oneOrMore>
              <element name="option">
                <interleave>
                  <attribute name="name"/>
                  <attribute name="value"/>
                </interleave>
              </element>
            </oneOrMore>
          </element>
        </optional>
        <optional>
          <element name="nostdmacros">
            <choice>
              <value>0</value>
              <value>1</value>
            </choice>
          </element>
        </optional>
        <optional>
          <element name="onlylog">
            <choice>
              <value>0</value>
              <value>1</value>
            </choice>
          </element>
        </optional>
        <optional>
          <element name="others_string">
            <text/>
          </element>
        </optional>
        <optional>
          <element name="output_align">
            <choice>
              <value>0</value>
              <value>1</value>
            </choice>
          </element>
        </optional>
        <optional>
          <element name="output_all_macrodefs">
            <choice>
              <value>0</value>
              <value>1</value>
            </choice>
          </element>
        </optional>
        <optional>
          <element name="output_annotation_marker">
            <text/>
          </element>
        </optional>
        <optional>
          <element name="output_directory">
            <text/>
          </element>
        </optional>
        <optional>
          <element name="output_encoding">
            <text/>
          </element>
        </optional>
        <optional>
          <element name="output_fieldcase">
            <choice>
              <value>upper</value>
              <value>lower</value>
              <value>title</value>
            </choice>
          </element>
        </optional>
        <optional>
          <element name="output_field_replace">
            <text/>
          </element>
        </optional>
        <optional>
          <element name="output_file">
            <text/>
          </element>
        </optional>
        <optional>
          <element name="output_format">
            <choice>
              <value>bibtex</value>
              <value>bbl</value>
              <value>biblatexml</value>
              <value>dot</value>
            </choice>
          </element>
        </optional>
        <optional>
          <element name="output_indent">
            <data type="unsignedByte"/>
          </element>
        </optional>
        <optional>
          <element name="output_listsep">
            <text/>
          </element>
        </optional>
        <optional>
          <element name="output_namesep">
            <text/>
          </element>
        </optional>
        <optional>
          <element name="output_no_macrodefs">
            <choice>
              <value>0</value>
              <value>1</value>
            </choice>
          </element>
        </optional>
        <optional>
          <element name="output_resolve_xdata">
            <choice>
              <value>0</value>
              <value>1</value>
            </choice>
          </element>
        </optional>
        <optional>
          <element name="output_resolve_crossrefs">
            <choice>
              <value>0</value>
              <value>1</value>
            </choice>
          </element>
        </optional>
        <optional>
          <element name="output_resolve_sets">
            <choice>
              <value>0</value>
              <value>1</value>
            </choice>
          </element>
        </optional>
        <optional>
          <element name="output_safechars">
            <choice>
              <value>0</value>
              <value>1</value>
            </choice>
          </element>
        </optional>
        <optional>
          <element name="output_safecharsset">
            <choice>
              <value>base</value>
              <value>full</value>
            </choice>
          </element>
        </optional>
        <optional>
          <element name="output_xdatamarker">
            <text/>
          </element>
        </optional>
        <optional>
          <element name="output_xdatasep">
            <text/>
          </element>
        </optional>
        <optional>
          <element name="output_xname">
            <choice>
              <value>0</value>
              <value>1</value>
            </choice>
          </element>
        </optional>
        <optional>
          <element name="output_xnamesep">
            <text/>
          </element>
        </optional>
        <optional>
          <element name="quiet">
            <choice>
              <value>0</value>
              <value>1</value>
            </choice>
          </element>
        </optional>
        <optional>
          <element name="recodedata">
            <text/>
          </element>
        </optional>
        <optional>
          <element name="sortcase">
            <choice>
              <value>0</value>
              <value>1</value>
            </choice>
          </element>
        </optional>
        <zeroOrMore>
          <ref name="translit"/>
        </zeroOrMore>
        <zeroOrMore>
          <ref name="labelalphanametemplate"/>
        </zeroOrMore>
        <optional>
          <ref name="labelalphatemplate"/>
        </optional>
        <zeroOrMore>
          <ref name="uniquenametemplate"/>
        </zeroOrMore>
        <optional>
          <ref name="sortingnamekeytemplate"/>
        </optional>
        <optional>
          <ref name="sortingtemplate"/>
        </optional>
        <zeroOrMore>
          <!-- presort default strings for different entry types -->
          <element name="presort">
            <optional>
              <attribute name="type"/>
            </optional>
            <text/>
          </element>
        </zeroOrMore>
        <zeroOrMore>
          <!-- excludes of certain fields for sorting for specified types -->
          <element name="sortexclusion">
            <attribute name="type"/>
            <oneOrMore>
              <element name="exclusion">
                <text/>
              </element>
            </oneOrMore>
          </element>
        </zeroOrMore>
        <zeroOrMore>
          <!-- forcibly includes certain fields excluded by sortexclusion for sorting for specified types -->
          <element name="sortinclusion">
            <attribute name="type"/>
            <oneOrMore>
              <element name="inclusion">
                <text/>
              </element>
            </oneOrMore>
          </element>
        </zeroOrMore>
        <optional>
          <element name="sortlocale">
            <text/>
          </element>
        </optional>
        <optional>
          <element name="sortupper">
            <choice>
              <value>0</value>
              <value>1</value>
            </choice>
          </element>
        </optional>
        <optional>
          <element name="sourcemap">
            <oneOrMore>
              <element name="maps">
                <attribute name="datatype">
                  <choice>
                    <value>bibtex</value>
                    <value>biblatexml</value>
                  </choice>
                </attribute>
                <optional>
                  <attribute name="map_overwrite">
                    <choice>
                      <value>0</value>
                      <value>1</value>
                    </choice>
                  </attribute>
                </optional>
                <oneOrMore>
                  <ref name="map"/>
                </oneOrMore>
              </element>
            </oneOrMore>
          </element>
        </optional>
        <optional>
          <element name="ssl-nointernalca">
            <choice>
              <value>0</value>
              <value>1</value>
            </choice>
          </element>
        </optional>
        <optional>
          <element name="ssl-noverify-host">
            <choice>
              <value>0</value>
              <value>1</value>
            </choice>
          </element>
        </optional>
        <optional>
          <element name="tool">
            <choice>
              <value>0</value>
              <value>1</value>
            </choice>
          </element>
        </optional>
        <optional>
          <element name="tool_config">
            <text/>
          </element>
        </optional>
        <optional>
          <element name="trace">
            <choice>
              <value>0</value>
              <value>1</value>
            </choice>
          </element>
        </optional>
        <optional>
          <element name="validate_config">
            <choice>
              <value>0</value>
              <value>1</value>
            </choice>
          </element>
        </optional>
        <optional>
          <element name="validate_control">
            <choice>
              <value>0</value>
              <value>1</value>
            </choice>
          </element>
        </optional>
        <optional>
          <element name="validate_datamodel">
            <choice>
              <value>0</value>
              <value>1</value>
            </choice>
          </element>
        </optional>
        <optional>
          <!--
            Meaningless in the config file
             element version              { "0" | "1" }? &
          -->
          <element name="wraplines">
            <choice>
              <value>0</value>
              <value>1</value>
            </choice>
          </element>
        </optional>
        <optional>
          <element name="xdatamarker">
            <text/>
          </element>
        </optional>
        <optional>
          <element name="xdatasep">
            <text/>
          </element>
        </optional>
        <optional>
          <element name="xname">
            <choice>
              <value>0</value>
              <value>1</value>
            </choice>
          </element>
        </optional>
        <optional>
          <element name="xnamesep">
            <text/>
          </element>
        </optional>
      </interleave>
    </element>
  </start>
  <define name="datamodel">
    <element name="datamodel">
      <!-- Constants -->
      <element name="constants">
        <oneOrMore>
          <element name="constant">
            <optional>
              <attribute name="type">
                <choice>
                  <value>string</value>
                  <value>list</value>
                </choice>
              </attribute>
            </optional>
            <attribute name="name"/>
            <text/>
          </element>
        </oneOrMore>
      </element>
      <!-- Valid entrytypes -->
      <element name="entrytypes">
        <oneOrMore>
          <element name="entrytype">
            <optional>
              <!-- Some entrytypes should be completely skipped on output (XDATA etc.) -->
              <attribute name="skip_output">
                <value>true</value>
              </attribute>
            </optional>
            <text/>
          </element>
        </oneOrMore>
      </element>
      <!--
        BibLaTeX field types. Biber uses this to determine how to output various types
        to the .bbl
      -->
      <element name="fields">
        <oneOrMore>
          <element name="field">
            <!-- fieldtype is "field" or "list" -->
            <attribute name="fieldtype">
              <ref name="dmfieldtype"/>
            </attribute>
            <optional>
              <!--
                format is a specification of the format of the field. If not specified, field contents
                are just as is. 
              -->
              <attribute name="format">
                <value>xsv</value>
              </attribute>
            </optional>
            <!-- datatype of field content -->
            <attribute name="datatype">
              <ref name="dmdatatype"/>
            </attribute>
            <optional>
              <!-- Are we allowed to output a null field value to the .bbl for this field? -->
              <attribute name="nullok">
                <value>true</value>
              </attribute>
            </optional>
            <optional>
              <!-- Should this field be skipped and not output to the .bbl? -->
              <attribute name="skip_output">
                <value>true</value>
              </attribute>
            </optional>
            <optional>
              <!-- Field can be used as a label? This auto-generates some defaults in biblatex -->
              <attribute name="label">
                <value>true</value>
              </attribute>
            </optional>
            <text/>
          </element>
        </oneOrMore>
      </element>
      <oneOrMore>
        <!--
          Allowable fields for entrytypes
          Only one specification per entrytype: even though it might be nice to have several 
          so that one could share information, this would be hard to manage and confusing as it
          not be visible in one place which fields were valid for an entrytype.
        -->
        <element name="entryfields">
          <zeroOrMore>
            <element name="entrytype">
              <text/>
            </element>
          </zeroOrMore>
          <oneOrMore>
            <element name="field">
              <text/>
            </element>
          </oneOrMore>
        </element>
      </oneOrMore>
      <!-- Allowable multiscript fields which can have alternate form/languages -->
      <element name="multiscriptfields">
        <oneOrMore>
          <element name="field">
            <text/>
          </element>
        </oneOrMore>
      </element>
      <oneOrMore>
        <!-- Constraints on field (co-)existence and format -->
        <element name="constraints">
          <zeroOrMore>
            <!--
              Set of entrytypes that this constraint applies to
              An entrytype can be specified in multiple constraints
              
            -->
            <element name="entrytype">
              <text/>
            </element>
          </zeroOrMore>
          <zeroOrMore>
            <!-- A constraint specification -->
            <element name="constraint">
              <choice>
                <!--
                  Conditional constraints have an antecedent and consequent
                  both of which have a quantifier. This allows you to enforce
                  constraints like:
                  
                  if field a,b,c are all present then one of x,y,z must be
                  if one of field a,b,c are present then none of x,y,z must be
                  etc.
                -->
                <group>
                  <attribute name="type">
                    <value>conditional</value>
                  </attribute>
                  <element name="antecedent">
                    <attribute name="quant">
                      <choice>
                        <value>all</value>
                        <value>one</value>
                        <value>none</value>
                      </choice>
                    </attribute>
                    <oneOrMore>
                      <element name="field">
                        <text/>
                      </element>
                    </oneOrMore>
                  </element>
                  <element name="consequent">
                    <attribute name="quant">
                      <choice>
                        <value>all</value>
                        <value>one</value>
                        <value>none</value>
                      </choice>
                    </attribute>
                    <oneOrMore>
                      <element name="field">
                        <text/>
                      </element>
                    </oneOrMore>
                  </element>
                </group>
                <!-- Datatype and format constraints -->
                <group>
                  <attribute name="type">
                    <value>data</value>
                  </attribute>
                  <optional>
                    <!-- range* attributes are for limiting integer type range -->
                    <attribute name="datatype">
                      <choice>
                        <value>integer</value>
                        <value>isbn</value>
                        <value>issn</value>
                        <value>ismn</value>
                        <value>date</value>
                        <value>pattern</value>
                      </choice>
                    </attribute>
                  </optional>
                  <optional>
                    <attribute name="rangemin">
                      <data type="int"/>
                    </attribute>
                  </optional>
                  <optional>
                    <attribute name="rangemax">
                      <data type="int"/>
                    </attribute>
                  </optional>
                  <optional>
                    <attribute name="pattern"/>
                  </optional>
                  <oneOrMore>
                    <element name="field">
                      <text/>
                    </element>
                  </oneOrMore>
                </group>
                <!-- Mandatoriness constraints which say which fields must appear -->
                <group>
                  <attribute name="type">
                    <value>mandatory</value>
                  </attribute>
                  <oneOrMore>
                    <choice>
                      <element name="field">
                        <text/>
                      </element>
                      <!--
                        An XOR set of fields so you can enforce:
                        
                        One (but not more) of fields a,b,c must exist
                      -->
                      <element name="fieldxor">
                        <oneOrMore>
                          <element name="field">
                            <text/>
                          </element>
                        </oneOrMore>
                      </element>
                      <!--
                        An OR set of fields so you can enforce:
                        
                        One (possibly more) of fields a,b,c must exist
                      -->
                      <element name="fieldor">
                        <oneOrMore>
                          <element name="field">
                            <text/>
                          </element>
                        </oneOrMore>
                      </element>
                    </choice>
                  </oneOrMore>
                </group>
              </choice>
            </element>
          </zeroOrMore>
        </element>
      </oneOrMore>
    </element>
  </define>
  <define name="translit">
    <element name="transliteration">
      <attribute name="entrytype">
        <choice>
          <value>*</value>
          <data type="string">
            <param name="minLength">1</param>
          </data>
        </choice>
      </attribute>
      <oneOrMore>
        <element name="translit">
          <attribute name="target">
            <choice>
              <value>*</value>
              <data type="string">
                <param name="minLength">1</param>
              </data>
            </choice>
          </attribute>
          <attribute name="from">
            <data type="string">
              <param name="minLength">1</param>
            </data>
          </attribute>
          <attribute name="to">
            <data type="string">
              <param name="minLength">1</param>
            </data>
          </attribute>
        </element>
      </oneOrMore>
    </element>
  </define>
  <define name="inheritance">
    <!-- Cross-reference inheritance specifications -->
    <element name="inheritance">
      <!-- Defaults -->
      <element name="defaults">
        <!-- Whether to inherit all fields -->
        <attribute name="inherit_all">
          <choice>
            <value>true</value>
            <value>false</value>
          </choice>
        </attribute>
        <!-- Should we overwrite the target field if it exists? -->
        <attribute name="override_target">
          <choice>
            <value>true</value>
            <value>false</value>
          </choice>
        </attribute>
        <optional>
          <!-- ignore of uniqueness tracking -->
          <attribute name="ignore"/>
        </optional>
        <zeroOrMore>
          <!-- Default inherit_all and override_target settings for entrytype source/target pairs -->
          <element name="type_pair">
            <attribute name="source">
              <choice>
                <value>*</value>
                <data type="string">
                  <param name="minLength">1</param>
                </data>
              </choice>
            </attribute>
            <attribute name="target">
              <choice>
                <value>*</value>
                <data type="string">
                  <param name="minLength">1</param>
                </data>
              </choice>
            </attribute>
            <optional>
              <attribute name="inherit_all">
                <choice>
                  <value>true</value>
                  <value>false</value>
                </choice>
              </attribute>
            </optional>
            <optional>
              <attribute name="override_target">
                <choice>
                  <value>true</value>
                  <value>false</value>
                </choice>
              </attribute>
            </optional>
            <optional>
              <attribute name="ignore"/>
            </optional>
            <empty/>
          </element>
        </zeroOrMore>
      </element>
      <zeroOrMore>
        <!-- An inheritance specification -->
        <element name="inherit">
          <optional>
            <!-- ignore of uniqueness tracking -->
            <attribute name="ignore"/>
          </optional>
          <oneOrMore>
            <!-- applies to these pairs of source/target entrytypes -->
            <element name="type_pair">
              <attribute name="source">
                <choice>
                  <value>*</value>
                  <data type="string">
                    <param name="minLength">1</param>
                  </data>
                </choice>
              </attribute>
              <attribute name="target">
                <choice>
                  <value>*</value>
                  <data type="string">
                    <param name="minLength">1</param>
                  </data>
                </choice>
              </attribute>
              <empty/>
            </element>
          </oneOrMore>
          <oneOrMore>
            <!-- and here are the field specifications -->
            <element name="field">
              <choice>
                <!--
                  either a "skip this field" specification
                  so we can say inherit all except certain fields OR ...
                -->
                <group>
                  <attribute name="source">
                    <data type="string"/>
                  </attribute>
                  <attribute name="skip">
                    <choice>
                      <value>true</value>
                      <value>false</value>
                    </choice>
                  </attribute>
                </group>
                <!-- ... a source and target field with an optional override attribute -->
                <group>
                  <attribute name="source">
                    <data type="string">
                      <param name="minLength">1</param>
                    </data>
                  </attribute>
                  <attribute name="target">
                    <data type="string">
                      <param name="minLength">1</param>
                    </data>
                  </attribute>
                  <optional>
                    <attribute name="override_target">
                      <choice>
                        <value>true</value>
                        <value>false</value>
                      </choice>
                    </attribute>
                  </optional>
                </group>
              </choice>
              <empty/>
            </element>
          </oneOrMore>
        </element>
      </zeroOrMore>
    </element>
  </define>
  <define name="map">
    <element name="map">
      <optional>
        <attribute name="map_overwrite">
          <choice>
            <value>0</value>
            <value>1</value>
          </choice>
        </attribute>
      </optional>
      <optional>
        <attribute name="map_foreach">
          <data type="string">
            <param name="minLength">1</param>
          </data>
        </attribute>
      </optional>
      <optional>
        <attribute name="refsection">
          <data type="integer"/>
        </attribute>
      </optional>
      <zeroOrMore>
        <element name="per_datasource">
          <data type="string">
            <param name="minLength">1</param>
          </data>
        </element>
      </zeroOrMore>
      <zeroOrMore>
        <element name="per_type">
          <data type="string">
            <param name="minLength">1</param>
          </data>
        </element>
      </zeroOrMore>
      <oneOrMore>
        <element name="map_step">
          <choice>
            <attribute name="map_entry_clone">
              <data type="string">
                <param name="minLength">1</param>
              </data>
            </attribute>
            <group>
              <attribute name="map_entry_new">
                <data type="string">
                  <param name="minLength">1</param>
                </data>
              </attribute>
              <attribute name="map_entry_newtype">
                <data type="string">
                  <param name="minLength">1</param>
                </data>
              </attribute>
            </group>
            <group>
              <optional>
                <attribute name="map_entrykey_cited">
                  <value>1</value>
                </attribute>
              </optional>
              <optional>
                <attribute name="map_entrykey_nocited">
                  <value>1</value>
                </attribute>
              </optional>
              <optional>
                <attribute name="map_entrykey_citedornocited">
                  <value>1</value>
                </attribute>
              </optional>
              <optional>
                <attribute name="map_entrykey_allnocited">
                  <value>1</value>
                </attribute>
              </optional>
              <optional>
                <attribute name="map_entrykey_starnocited">
                  <value>1</value>
                </attribute>
              </optional>
              <optional>
                <attribute name="map_type_source">
                  <data type="string">
                    <param name="minLength">1</param>
                  </data>
                </attribute>
              </optional>
              <optional>
                <attribute name="map_type_target">
                  <data type="string">
                    <param name="minLength">1</param>
                  </data>
                </attribute>
              </optional>
              <optional>
                <attribute name="map_field_source">
                  <data type="string">
                    <param name="minLength">1</param>
                  </data>
                </attribute>
              </optional>
              <optional>
                <attribute name="map_notfield">
                  <data type="string">
                    <param name="minLength">1</param>
                  </data>
                </attribute>
              </optional>
              <optional>
                <attribute name="map_field_target">
                  <data type="string">
                    <param name="minLength">1</param>
                  </data>
                </attribute>
              </optional>
              <optional>
                <attribute name="map_entrytarget">
                  <data type="string">
                    <param name="minLength">1</param>
                  </data>
                </attribute>
              </optional>
              <optional>
                <attribute name="map_field_set">
                  <data type="string">
                    <param name="minLength">1</param>
                  </data>
                </attribute>
              </optional>
              <optional>
                <attribute name="map_entry_null">
                  <value>1</value>
                </attribute>
              </optional>
              <optional>
                <attribute name="map_append">
                  <value>1</value>
                </attribute>
              </optional>
              <optional>
                <attribute name="map_appendstrict">
                  <value>1</value>
                </attribute>
              </optional>
              <optional>
                <attribute name="map_final">
                  <value>1</value>
                </attribute>
              </optional>
              <optional>
                <attribute name="map_match">
                  <data type="string">
                    <param name="minLength">1</param>
                  </data>
                </attribute>
              </optional>
              <optional>
                <attribute name="map_matchi">
                  <data type="string">
                    <param name="minLength">1</param>
                  </data>
                </attribute>
              </optional>
              <optional>
                <attribute name="map_notmatch">
                  <data type="string">
                    <param name="minLength">1</param>
                  </data>
                </attribute>
              </optional>
              <optional>
                <attribute name="map_notmatchi">
                  <data type="string">
                    <param name="minLength">1</param>
                  </data>
                </attribute>
              </optional>
              <optional>
                <attribute name="map_replace">
                  <data type="string"/>
                </attribute>
              </optional>
              <optional>
                <choice>
                  <attribute name="map_null">
                    <value>1</value>
                  </attribute>
                  <attribute name="map_origfield">
                    <value>1</value>
                  </attribute>
                  <attribute name="map_origfieldval">
                    <value>1</value>
                  </attribute>
                  <attribute name="map_origentrytype">
                    <value>1</value>
                  </attribute>
                  <attribute name="map_field_value">
                    <data type="string">
                      <param name="minLength">1</param>
                    </data>
                  </attribute>
                </choice>
              </optional>
            </group>
          </choice>
          <empty/>
        </element>
      </oneOrMore>
    </element>
  </define>
  <define name="labelalphanametemplate">
    <element name="labelalphanametemplate">
      <optional>
        <attribute name="name">
          <data type="string"/>
        </attribute>
      </optional>
      <oneOrMore>
        <element name="namepart">
          <attribute name="order">
            <data type="integer"/>
          </attribute>
          <optional>
            <attribute name="use">
              <choice>
                <value>0</value>
                <value>1</value>
              </choice>
            </attribute>
          </optional>
          <optional>
            <attribute name="pre">
              <choice>
                <value>0</value>
                <value>1</value>
              </choice>
            </attribute>
          </optional>
          <optional>
            <attribute name="substring_width">
              <data type="integer"/>
            </attribute>
          </optional>
          <optional>
            <attribute name="substring_compound">
              <choice>
                <value>0</value>
                <value>1</value>
              </choice>
            </attribute>
          </optional>
          <optional>
            <attribute name="substring_side">
              <choice>
                <value>left</value>
                <value>right</value>
              </choice>
            </attribute>
          </optional>
          <text/>
        </element>
      </oneOrMore>
    </element>
  </define>
  <define name="labelalphatemplate">
    <element name="labelalphatemplate">
      <optional>
        <attribute name="type">
          <data type="string"/>
        </attribute>
      </optional>
      <oneOrMore>
        <!-- per-type? -->
        <element name="labelelement">
          <attribute name="order">
            <data type="integer"/>
          </attribute>
          <oneOrMore>
            <element name="labelpart">
              <optional>
                <attribute name="final">
                  <choice>
                    <value>0</value>
                    <value>1</value>
                  </choice>
                </attribute>
              </optional>
              <optional>
                <attribute name="pad_char">
                  <data type="string">
                    <param name="minLength">1</param>
                  </data>
                </attribute>
              </optional>
              <optional>
                <attribute name="pad_side">
                  <choice>
                    <value>left</value>
                    <value>right</value>
                  </choice>
                </attribute>
              </optional>
              <optional>
                <attribute name="substring_width">
                  <choice>
                    <data type="integer"/>
                    <value>v</value>
                    <value>vf</value>
                    <value>l</value>
                  </choice>
                </attribute>
              </optional>
              <optional>
                <attribute name="substring_fixed_threshold">
                  <data type="integer"/>
                </attribute>
              </optional>
              <optional>
                <attribute name="substring_width_max">
                  <data type="integer"/>
                </attribute>
              </optional>
              <optional>
                <attribute name="substring_side">
                  <choice>
                    <value>left</value>
                    <value>right</value>
                  </choice>
                </attribute>
              </optional>
              <optional>
                <attribute name="ifnames"/>
              </optional>
              <optional>
                <attribute name="names"/>
              </optional>
              <optional>
                <attribute name="namessep">
                  <data type="string" datatypeLibrary=""/>
                </attribute>
              </optional>
              <optional>
                <attribute name="noalphaothers">
                  <choice>
                    <value>0</value>
                    <value>1</value>
                  </choice>
                </attribute>
              </optional>
              <data type="string"/>
            </element>
          </oneOrMore>
        </element>
      </oneOrMore>
    </element>
  </define>
  <define name="uniquenametemplate">
    <element name="uniquenametemplate">
      <attribute name="name">
        <data type="string">
          <param name="minLength">1</param>
        </data>
      </attribute>
      <oneOrMore>
        <element name="namepart">
          <attribute name="order">
            <data type="integer"/>
          </attribute>
          <optional>
            <attribute name="use">
              <choice>
                <value>0</value>
                <value>1</value>
              </choice>
            </attribute>
          </optional>
          <optional>
            <attribute name="base">
              <choice>
                <value>0</value>
                <value>1</value>
              </choice>
            </attribute>
          </optional>
          <optional>
            <attribute name="context">
              <choice>
                <value>none</value>
                <value>init</value>
                <value>initorfull</value>
                <value>full</value>
              </choice>
            </attribute>
          </optional>
          <text/>
        </element>
      </oneOrMore>
    </element>
  </define>
  <define name="sortingnamekeytemplate">
    <element name="sortingnamekeytemplate">
      <attribute name="name"/>
      <oneOrMore>
        <element name="keypart">
          <attribute name="order">
            <data type="integer"/>
          </attribute>
          <oneOrMore>
            <element name="part">
              <attribute name="type">
                <choice>
                  <value>namepart</value>
                  <value>literal</value>
                </choice>
              </attribute>
              <attribute name="order">
                <data type="integer"/>
              </attribute>
              <optional>
                <attribute name="use">
                  <choice>
                    <value>0</value>
                    <value>1</value>
                  </choice>
                </attribute>
              </optional>
              <optional>
                <attribute name="inits">
                  <choice>
                    <value>0</value>
                    <value>1</value>
                  </choice>
                </attribute>
              </optional>
              <text/>
            </element>
          </oneOrMore>
        </element>
      </oneOrMore>
    </element>
  </define>
  <define name="sortingtemplate">
    <element name="sortingtemplate">
      <!-- sorting template name -->
      <attribute name="name">
        <data type="string">
          <param name="minLength">1</param>
        </data>
      </attribute>
      <optional>
        <!-- locale for entire sorting specification -->
        <attribute name="locale">
          <data type="string">
            <param name="minLength">1</param>
          </data>
        </attribute>
      </optional>
      <oneOrMore>
        <ref name="sort"/>
      </oneOrMore>
    </element>
  </define>
  <define name="sort">
    <oneOrMore>
      <!-- sort specification -->
      <element name="sort">
        <!-- order of this specification in the set of all sort specifications -->
        <attribute name="order">
          <data type="integer"/>
        </attribute>
        <optional>
          <!-- Should we stop generating sorting information after this item? -->
          <attribute name="final">
            <value>1</value>
          </attribute>
        </optional>
        <optional>
          <!-- Sort ascending or descending -->
          <attribute name="sort_direction">
            <choice>
              <value>ascending</value>
              <value>descending</value>
            </choice>
          </attribute>
        </optional>
        <optional>
          <!-- Sort case sensitive or not? -->
          <attribute name="sortcase">
            <choice>
              <value>0</value>
              <value>1</value>
            </choice>
          </attribute>
        </optional>
        <optional>
          <!-- Sort upper before lower? -->
          <attribute name="sortupper">
            <choice>
              <value>0</value>
              <value>1</value>
            </choice>
          </attribute>
        </optional>
        <optional>
          <!-- sortset specific override for locale -->
          <attribute name="locale">
            <data type="string">
              <param name="minLength">1</param>
            </data>
          </attribute>
        </optional>
        <oneOrMore>
          <!-- A sort item specification - a field or pseudo-field to get sort information from -->
          <element name="sortitem">
            <!-- order of this item in the set of all other item specifications -->
            <attribute name="order">
              <data type="integer"/>
            </attribute>
            <optional>
              <!-- Just use a part of the item information for sorting? -->
              <attribute name="substring_side">
                <choice>
                  <value>left</value>
                  <value>right</value>
                </choice>
              </attribute>
            </optional>
            <optional>
              <attribute name="substring_width">
                <data type="integer"/>
              </attribute>
            </optional>
            <optional>
              <!-- Pad the item information when sorting with it? -->
              <attribute name="pad_side">
                <choice>
                  <value>left</value>
                  <value>right</value>
                </choice>
              </attribute>
            </optional>
            <optional>
              <attribute name="pad_width">
                <data type="integer"/>
              </attribute>
            </optional>
            <optional>
              <attribute name="pad_char">
                <data type="string">
                  <param name="minLength">1</param>
                  <param name="maxLength">1</param>
                </data>
              </attribute>
            </optional>
            <optional>
              <attribute name="form">
                <choice>
                  <value>original</value>
                  <value>translated</value>
                  <value>romanised</value>
                  <value>uniform</value>
                </choice>
              </attribute>
            </optional>
            <text/>
          </element>
        </oneOrMore>
      </element>
    </oneOrMore>
  </define>
  <define name="dmfieldtype">
    <choice>
      <value>field</value>
      <value>list</value>
    </choice>
  </define>
  <define name="dmdatatype">
    <choice>
      <value>literal</value>
      <value>name</value>
      <value>key</value>
      <value>entrykey</value>
      <value>date</value>
      <value>verbatim</value>
      <value>integer</value>
      <value>range</value>
      <value>code</value>
      <value>uri</value>
      <value>datepart</value>
      <value>keyword</value>
      <value>option</value>
    </choice>
  </define>
</grammar>
<!-- Copyright 2012-2020 Philip Kime, all rights reserved. -->
<!--
  This code is free software.  You can redistribute it and/or
  modify it under the terms of the Artistic License 2.0.
-->
<!--
  This program is distributed in the hope that it will be useful,
  but without any warranty; without even the implied warranty of
  merchantability or fitness for a particular purpose.
-->
