<?xml version="1.0" encoding="UTF-8"?>
<grammar
	xmlns="http://relaxng.org/ns/structure/1.0"
	xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0"
	xmlns:w="http://www.wulfila.be/namespaces/legacy"
	datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
	<a:documentation>Schema for the lemmas data file.</a:documentation>
	<!-- 
	Revision history:
	[2026-05-19] First draft.
	[2026-05-20] First full version.
	[2026-05-24] Finished documentation.
	[2026-07-31] Removed information about Streitberg's lemma entry, as it is already defined (more accurately) in the XML transcription of Streitberg 1910. 
	
	Tom De Herdt
	https://www.wulfila.be/
	-->
	
	<include href="common.rng">
		<start>
			<ref name="root"/>
		</start>
	</include>
	
	<define name="root">
		<element name="lemmas">
			<oneOrMore>
				<ref name="lemma"/>
			</oneOrMore>
		</element>
	</define>
	
	<define name="lemma">
		<element name="lemma">
			<attribute name="id">
				<a:documentation>Lemma identifier.</a:documentation>
				<data type="positiveInteger"/>
			</attribute>
			<optional>
				<attribute name="parent">
					<a:documentation>Foreign key: identifier of another lemma that this lemma refers to, because it is a link or related lemma.</a:documentation>
					<data type="positiveInteger"/>
				</attribute>
			</optional>
			<optional>
				<attribute name="problematic">
					<a:documentation>Lemma does not fit neatly into the schema, or is otherwise problematic. See internal note in &lt;meta&gt;.</a:documentation>
					<ref name="boolean.attribute.true"/>
				</attribute>
			</optional>
			<optional>
				<attribute name="disambiguated">
					<a:documentation>All occurrences of the lemma have been located, disambiguated and checked against Snædal.</a:documentation>
					<ref name="boolean.attribute.true"/>
				</attribute>
			</optional>
			<attribute name="type">
				<a:documentation>Lemma type.</a:documentation>
				<ref name="list.lemma.type"/>
			</attribute>
			<optional>
				<attribute name="verified">
					<a:documentation>Last verification date. (The dictionary has been checked twice.)</a:documentation>
					<data type="dateTime"/>
				</attribute>
			</optional>
			<element name="form">
				<a:documentation>Primary orthographical form of the lemma or headword.</a:documentation>
				<ref name="form.content"/>
			</element>
			<zeroOrMore>
				<element name="variant">
					<a:documentation>Variant orthographical form of the lemma, e.g. a spelling variant or a form with diacritical marks used in a specific dictionary. NOT used for alternative reconstructions with different inflection class: these are linked to the lemma as separate headwords with type "alternative".</a:documentation>
					<optional>
						<attribute name="type">
							<choice>
								<value>spelling</value>
								<a:documentation>Variant form is a spelling variation in some reading.</a:documentation>
								
								<value>diacritics</value>
								<a:documentation>Variant form is a headword with diacritical marks, used in a dictionary specified in @source.</a:documentation>
							</choice>
						</attribute>
					</optional>
					<optional>
						<attribute name="source">
							<a:documentation>Token or siglum referring to the source that uses or mentions the variant form.</a:documentation>
						</attribute>
					</optional>
					<ref name="form.content"/>
				</element>
			</zeroOrMore>
			<element name="pos">
				<a:documentation>Foreign key: identifier of a part-of-speech tag defined in the grammar data file.</a:documentation>
				<data type="unsignedByte"/>
			</element>
			<element name="inflection">
				<attribute name="class">
					<a:documentation>Foreign key: identifier of an inflection class defined the grammar data file.</a:documentation>
					<data type="unsignedByte"/>
				</attribute>
				<optional>
					<attribute name="irregular">
						<a:documentation>Lemma has irregular inflection.</a:documentation>
						<ref name="boolean.attribute.true"/>
					</attribute>
				</optional>
				<optional>
					<attribute name="uncertain">
						<a:documentation>The assigned inflection class is not certain (Streitberg's label contains a question mark or other indication of uncertainty).</a:documentation>
						<ref name="boolean.attribute.true"/>
					</attribute>
				</optional>
				<zeroOrMore>
					<element name="param">
						<a:documentation>Gomorphv2 parameter.</a:documentation>
						<attribute name="name">
							<a:documentation>Parameter name.</a:documentation>
							<data type="NCName"/>
						</attribute>
						<optional>
							<attribute name="type">
								<a:documentation>Parameter type.</a:documentation>
								<choice>
									<value>info</value><a:documentation>Temporary or informational parameter, not passed on to Gomorphv2.</a:documentation>
								</choice>
							</attribute>
						</optional>
						<choice>
							<text/>
							<ref name="null"/>
						</choice>
					</element>
				</zeroOrMore>
				<zeroOrMore>
					<element name="override">
						<a:documentation>Gomorphv2 override rule.</a:documentation>
						<attribute name="variable">
							<a:documentation>Name of the Gomorph variable that will be overridden.</a:documentation>
							<data type="NCName"/>
						</attribute>
						<attribute name="operator">
							<a:documentation>Gomorphv2 operator: assign, add or remove.</a:documentation>
							<choice>
								<value>assign</value>
								<value>add</value>
								<value>remove</value>
							</choice>
						</attribute>
						<optional>
							<attribute name="range">
								<a:documentation>Gomorphv2 range expression (regular expression applied to the set of inflectional tags). When missing, all tags are selected.</a:documentation>
							</attribute>
						</optional>
						<choice>
							<text/>
							<ref name="null"/>
						</choice>
					</element>
				</zeroOrMore>
			</element>
			<optional>
				<ref name="streitberg"/>
			</optional>
			<optional>
				<element name="note">
					<a:documentation>Public note about the lemma.</a:documentation>
					<text/>
				</element>
			</optional>
			<optional>
				<element name="meta">
					<a:documentation>Internal note about the lemma or its encoding, in Dutch.</a:documentation>
					<text/>
				</element>
			</optional>
		</element>
	</define>
	
	<define name="form.content">
		<a:documentation>Headword form content.</a:documentation>
		<optional>
			<attribute name="conjecture">
				<a:documentation>Lemma is a conjecture.</a:documentation>
				<ref name="boolean.attribute.true"/>
			</attribute>
		</optional>
		<optional>
			<attribute name="inflected">
				<a:documentation>Lemma is an inflected form (a headword cannot be reconstructed with certainty).</a:documentation>
				<ref name="boolean.attribute.true"/>
			</attribute>
		</optional>
		<optional>
			<attribute name="reconstruction">
				<a:documentation>Lemma is a reconstruction that leaves some room for doubt (marked with * in Streitberg).</a:documentation>
				<ref name="boolean.attribute.true"/>
			</attribute>
		</optional>
		<optional>
			<attribute name="suspect">
				<a:documentation>Lemma is a dubious or suspect reading (marked with dagger in Streitberg).</a:documentation>
				<ref name="boolean.attribute.true"/>
			</attribute>
		</optional>
		<text/>
	</define>
	
	<define name="streitberg">
		<element name="streitberg">
			<a:documentation>Reference to the corresponding lemma in Wilhelm Streitberg's dictionary (1910), encoded in a separate XML file. Entries in the external dictionary file also refer to lemma identifiers in this file, so strictly speaking this element is redundant; we retain a direct reference because the list started as a database of Streitberg's dictionary, and is still closely tied to that source.</a:documentation>
			<attribute name="page">
				<a:documentation>Page number in Streitberg 1910.</a:documentation>
				<data type="positiveInteger"/>
			</attribute>
			<attribute name="position">
				<a:documentation>Position of the headword on the page.</a:documentation>
				<data type="positiveInteger"/>
			</attribute>
			<attribute name="letter">
				<a:documentation>Letter under which the lemma is filed. This is not necessarily the initial: compound verbs are sorted on stem.</a:documentation>
				<data type="string">
					<param name="pattern">[A-ZǶÞ]</param>
				</data>
			</attribute>
			<optional>
				<attribute name="n">
					<a:documentation>Index number used by Streitberg to differentiate homonyms, e.g. “1. gabaur (Na)” and “2. gabaur* (Ma)”. Lemmas with type ‘homograph’ are grouped and numbered under a single headword in the dictionary; otherwise headwords are repeated, with a number before the boldfaced lemma.</a:documentation>
					<data type="positiveInteger"/>
				</attribute>
			</optional>
			<!--
				Information defined below has been REMOVED, as Streitberg's lemma is already encoded (more accurately) in the XML transcription of his dictionary.
				That transcription is now the ‘single source of truth’ for Streitberg's dictionary, and the lemma list presented here may deviate from Streitberg.
				tdh.20260731
			-->
			<!--
			<optional>
				<attribute name="conjecture">
					<a:documentation>Lemma is a conjecture, in square brackets. Streitberg: “Durch Konjektur entstandene Formen stehn in eckigen Klammern [].”</a:documentation>
					<ref name="boolean.attribute.true"/>
				</attribute>
			</optional>
			<optional>
				<attribute name="reconstruction">
					<a:documentation>Lemma is a reconstruction, marked with asterisk. Streitberg: <span xml:lang="de">“ein Stern (*) nach einer Form [deutet an], daß die zitierte Form in unserer Überlieferung zufällig fehlt, ihre Erschließung aber aus irgendeinem Grund dem Zweifel Raum läßt.”</span></a:documentation>
					<ref name="boolean.attribute.true"/>
				</attribute>
			</optional>
			<optional>
				<attribute name="suspect">
					<a:documentation>Lemma is a dubious reading, marked with dagger. Streitberg: “ein Kreuz (†) vor einer Form charakterisiert die handschriftliche Überlieferung als besserungsbedürftig.”</a:documentation>
					<ref name="boolean.attribute.true"/>
				</attribute>
			</optional>
			<optional>
				<element name="form">
					<a:documentation>Orthographical form used by Streitberg, when it differs from the lemma form used in this data file.</a:documentation>
					<text/>
				</element>
			</optional>
			<optional>
				<element name="formInfo">
					<a:documentation>Information following the lemma in Streitberg's lexicon, mostly on spelling, phonology or grammar, with references to Streitberg's Gotisches Elementarbuch (1920).</a:documentation>
					<text/>
				</element>
			</optional>
			<optional>
				<element name="grammar">
					<a:documentation>Grammar/morphology label used by Streitberg.</a:documentation>
					<optional>
						<attribute name="implied">
							<a:documentation>Streitberg's label is implied, i.e. omitted in the dictionary because the lemma is a compound; only the root lemma mentions the class.</a:documentation>
							<ref name="boolean.attribute.true"/>
						</attribute>
					</optional>
					<optional>
						<attribute name="base">
							<a:documentation>Normalized, corrected or general class label (used elsewhere by Streitberg), to facilitate grouping and searching.</a:documentation>
						</attribute>
						<attribute name="type">
							<a:documentation>Specifies the relation between @base and the label used by Streitberg.</a:documentation>
							<choice>
								<value>variation</value>
								<a:documentation>Alternate spelling or wording, e.g. ‘Akk.Pl.’ for ‘Akk.Plur.’.</a:documentation>
								
								<value>subclass</value>
								<a:documentation>Subset of the generic class, e.g. ‘st.Adj.a’ for ‘Adj.a’.</a:documentation>
								
								<value>uncertain</value>
								<a:documentation>Hypothesis, e.g. ‘M?a’ or ‘M(i)’.</a:documentation>
								
								<value>irregular</value>
								<a:documentation>Irregular instance of the generic class, e.g. ‘unreg.abl.V.1’.</a:documentation>
								
								<value>error</value>
								<a:documentation>Obvious error, e.g. spillon ‘sw.V.1’ for ‘sw.V.2’.</a:documentation>
							</choice>
						</attribute>
					</optional>
					<text/>
				</element>
			</optional>
			<optional>
				<element name="grammarInfo">
					<a:documentation>Information that follows the class label in Streitberg's lexicon, mostly on morphology.</a:documentation>
					<text/>
				</element>
			</optional>
			<optional>
				<element name="sense">
					<a:documentation>German translation by Streitberg. Incomplete and no longer updated: see XML transcription of the dictionary.</a:documentation>
					<text/>
				</element>
			</optional>
			-->
		</element>
	</define>
	
	<define name="null">
		<element name="null">
			<a:documentation>Gomorphv2 NULL value.</a:documentation>
			<empty/>
		</element>
	</define>
	
	<define name="list.lemma.type">
		<choice>
			<value>normal</value>
			<a:documentation w:id="1" w:streitberg="true" w:generate="true">Normal lemma.</a:documentation>
			
			<value>link-spelling</value>
			<a:documentation w:id="2" w:streitberg="true" w:generate="false">Reference to another lemma (@parent), for which it has an alternative spelling. Streitberg only, not linked to tokens.</a:documentation>
			
			<value>link-hyphen</value>
			<a:documentation w:id="3" w:streitberg="true" w:generate="false">Reference to another, identical lemma (@parent), the only difference being the use of a hyphen to separate root and prefix. Streitberg only, not linked to tokens.</a:documentation>
			
			<value>link-derived</value>
			<a:documentation w:id="4" w:streitberg="true" w:generate="false">Inflected form of another lemma, listed as a separate lemma with reference to the main lemma (@parent), e.g. ‘wait’ linked to ‘witan’. Streitberg only, not linked to tokens.</a:documentation>
			
			<value>link-suppletion</value>
			<a:documentation w:id="5" w:streitberg="true" w:generate="true">Suppletive form listed as a separate lemma, e.g. ‘batiza’ linked to ‘goþs’.</a:documentation>
			
			<value>link-spelling-combined</value>
			<a:documentation w:id="6" w:streitberg="true" w:generate="false">Combined spelling variants referring to multiple main lemmas, e.g. ‘leikeis, leikeinassus s. lekeis etc.’ Streitberg only, not linked to tokens.</a:documentation>
			
			<value>link-conjecture</value>
			<a:documentation w:id="7" w:streitberg="true" w:generate="false">Form marked as ‘besserungsbedürftig’ (with dagger), referring to a corresponding conjecture (or the other way round).</a:documentation>
			
			<value>homograph</value>
			<a:documentation w:id="9" w:streitberg="true" w:generate="true">One lemma out of a set of homographs that is treated as one entry in Streitberg's lexicon (cf. TEI &lt;hom&gt;).</a:documentation>
			
			<value>sublemma</value>
			<a:documentation w:id="10" w:streitberg="true" w:generate="true">Lemma mentioned as a related or derived lemma in Streitberg's lexicon (cf. TEI &lt;re&gt;). Attribute @parent refers to the main lemma.</a:documentation>
			
			<value>component</value>
			<a:documentation w:id="11" w:streitberg="true" w:generate="false">Clitic (e.g. ‘-hun’) or root form (e.g. ‘-kunnan’).</a:documentation>
			
			<value>alternative</value>
			<a:documentation w:id="12" w:streitberg="false" w:generate="false">Alternative reconstruction for the lemma specified by @parent. Not listed as a separate lemma in Streitberg.</a:documentation>
			
			<value>extra</value>
			<a:documentation w:id="13" w:streitberg="false" w:generate="true">Lemma not in Streitberg, either because it is accidentally missing, or because it refers to words in a recently discovered fragment.</a:documentation>
		</choice>
	</define>

</grammar>