<!--

By: Tomoko Okuno
On: Summer 2003
To: output an academic lexicon based on the Biao-Min lexicon xml file

-->

<!--This is a stylesheet -->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:field="http://www.emeld.org/field/namespace" xmlns:xs="http://www.w3.org/2001/XMLSchema">

<!--The xsl:template tag defines the start of a template. The match="/" attribute matches the template to the root (/) of the XML source document.-->
	<xsl:template match="/">
	
	<!-- Now we insert the html tags we want in the output. -->
		<html>
			<head>
				<title>Biao Min Stylesheets</title>
				<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
			</head>
			<body>
			
			<!--The "lexicon" element is the root element in the xml file.  This tag says, each time you encounter a "lexicon" tag, do everything contained in the xsl:for-each tag -->
				<xsl:for-each select="lexicon">
				
				<!-- html tags -->
					<br/>
					<span style="font-family:Arial Unicode MS;font-size:large; color:#666699; ">Biao Min</span>&#160;
     					<br/>
					<span style="font-family:Arial Unicode MS;font-size:small;color:#666699; ">
						<b>Field Linguist:</b>
					</span>
					
					<!--  This is a loop.   The @ symbol means 'attribute'  Each time you encounter an "linguist" attribute (of the lexicon element)  in the xml file, do what is contained in the :xsl for-each tag. 
					-->
					<xsl:for-each select="@linguist">
						<span style="font-family:Arial Unicode MS;color:#666699;  ">
							<!-- Output the value of the current node.  Since we are currently in the linguist attribute, the information contained in it will be output-->
							<xsl:value-of select="."/>
						</span>
						
						<!-- this tag closes the loop -->
					</xsl:for-each>
					
					<!-- html tags -->
					<br/><br/>
					<span style="font-family:Arial Unicode MS;color:#0033ff;font-size:11; ">
						Note: These demonstration sound files are not by a native speaker of Biao Min.
					</span>

					<table width="780">
					
					<!-- This tells the xml-parser, each time you encounter a forms element, do what is contained within the tags.-->
						<xsl:for-each select="forms">
						<!--Each time you encounter a form element, do what is contained within the tags-->
							<xsl:for-each select="form">
							<!-- This says, if the lang attribute (@) of the form element is Biao-jiao Mien, do what is contained within the tags. -->
								<xsl:if test="@lang='Biao-jiao Mien'">
									<br/>
									<br/>
									<!--loop through each "linguisticform" element-->
									<xsl:for-each select="linguisticform">
										<!--loop through each "unanalyzedform element-->

										<xsl:for-each select="unanalyzedform">
											
											<span style="font-family:Arial Unicode MS;font-weight:bold;color:red;font-size:16; ">
												
												<!--Output the value of the current node. We are currently in the "unanalyzedform" node, this will output its value. -->

												<xsl:value-of select="."/>

											</span>
											
										<!-- This tag closes the unanalyzedform loop. -->

										</xsl:for-each>
									<!-- This tag closes the linguisticform loop. -->
									</xsl:for-each>
									
									<span style="font-family:Arial Unicode MS; ">&#160;</span>
									<span style="font-family:Arial Unicode MS; ">&#160;</span>
									<span style="font-family:Arial Unicode MS; ">&#160;</span>
									<!-- For each id attribute of the form element... -->
									<xsl:for-each select="@id">
										<!-- The '.' contained within curly brackets inserts the value of the id attribute into the html href tag -->
										<a href="sound/mp3/{.}.mp3">
											<img src="audio.gif" border="0"/>
										</a>
									</xsl:for-each>
									<span style="font-family:Arial Unicode MS; ">&#160;</span>
									<span style="font-family:Arial Unicode MS; ">&#160;</span>
									<span style="font-family:Arial Unicode MS; ">&#160;</span>
									<xsl:for-each select="grammatical-relation">
									
									<!--The xsl:choose element is used with xsl:when and xsl:otherwise to express multiple conditional tests. -->
										<xsl:choose>
										<!-- When the attribute pos equals noun, do what is contained in the tags. -->
											<xsl:when test="@pos='Noun'">
												<xsl:for-each select="@pos">
													<span style="font-family:Arial Unicode MS;color:#666699; font-style:italic;  ">
														<small>n</small>
													</span>
												</xsl:for-each>
												<!--close the when tag -->
											</xsl:when>
											<xsl:when test="@pos='Verb'">
												<xsl:for-each select="@pos">
													<span style="font-family:Arial Unicode MS;color:#666699; font-style:italic;  ">
														<small>v</small>
													</span>
												</xsl:for-each>
											</xsl:when>
											<xsl:when test="@pos='Numeral'">
												<xsl:for-each select="@pos">
													<span style="font-family:Arial Unicode MS;color:#666699; font-style:italic;  ">
														<small>num</small>
													</span>
												</xsl:for-each>
											</xsl:when>
											
											<!-- If none of the xsl:when tests are met, do what is contained in the xsl:otherwise tags. -->
											<xsl:otherwise>
												
											</xsl:otherwise>
										<!--close the xsl:choose tag -->	
										</xsl:choose>
										<!--This tag closes thegrammatical-relation loop. -->									</xsl:for-each>

									<span style="font-family:Arial Unicode MS; ">&#160;</span>
									<span style="font-family:Arial Unicode MS; ">&#160;</span>
									<xsl:for-each select="gloss">
										<xsl:if test="@lang='English'">
											<xsl:for-each select="@value">
												<span style="font-family:Arial Unicode MS;color:#666699; ">
													<xsl:value-of select="."/>
												</span>
											</xsl:for-each>
										</xsl:if>
									</xsl:for-each>
									<br/>
									
									<!-- The xsl:if tag says 'use this template if a condition is true.  Here, we are testing if the compare element IS NOT NULL. -->
									<xsl:if test="compare != ' '">
									<!--Loop through the compare elements that are found (they are not null). -->
										<xsl:for-each select="compare">
											<span style="font-family:Arial Unicode MS; ">&#160;</span>
											<span style="font-family:Arial Unicode MS; ">&#160;</span>
											<span style="font-family:Arial Unicode MS; ">&#160;</span>
											<span style="font-family:Arial Unicode MS; ">&#160;</span>
											<!-- If the relation-term element equals 'Cognate', step into the tags.  -->
											<xsl:if test="relation-term='Cognate'">
												<!--loop through the relation-term elements -->
												<xsl:for-each select="relation-term">
													<span style="font-family:Arial Unicode MS;color:#666699; ">
														<small>Cog:</small>																									</span>
												</xsl:for-each>
											</xsl:if>
											<!-- If the relation-term element equals 'Loan Word Source', step into the tag.  -->

											<xsl:if test="relation-term='Loan Word Source'">
												<xsl:for-each select="relation-term">
													<span style="font-family:Arial Unicode MS;color:#666699; ">
														<small>Loan:</small>																								</span>
												</xsl:for-each>
											</xsl:if>
											<!-- If the relation-term element equals 'Compare'', step into the tag.  -->

											<xsl:if test="relation-term='Compare'">
												<xsl:for-each select="relation-term">
													<span style="font-family:Arial Unicode MS;color:#666699; ">
														<small>Comp:</small>																								</span>
												</xsl:for-each>
											</xsl:if>
											<span style="font-family:Arial Unicode MS; ">&#160;</span>
											<!-- Loop through the compare-link elements and apply everything within the tags. -->
											<xsl:for-each select="compare-link">
												<span style="font-family:Arial Unicode MS;color:#666699;font-weight:bold; ">
													<!--This tag applys any matching templates in the xsl file to the current node and its children. -->
													<xsl:apply-templates/>
												</span>
												<span style="font-family:Arial Unicode MS;color:#666699; ">&#160;</span>
												<!-- Loop through the lang attribute and apply everything within the tags. Remember we are currently in the compare-link element, so this tag loops through lang attributes of the compare-link element. -->

												<xsl:for-each select="@lang">
													<span style="font-family:Arial Unicode MS;color:#666699; ">
														<small>(<xsl:value-of select="."/>)</small>																					</span>
												<!-- This tag closes the lang loop. -->
												</xsl:for-each>
											<!-- This tag closes the compare-link loop. -->
											</xsl:for-each>
											<br/>
										<!-- This tag closes the compare loop. -->

										</xsl:for-each>
									<!-- This tag closes the 'if compare is not null' condition. --> 
									</xsl:if>
								<!-- This tag closes the lang attribute of the form element is equal to'Biao-jiao Mien' condition. -->
								</xsl:if>
							<!-- This tag closes the form loop.	-->
							</xsl:for-each>
						<!-- This tag closes the forms loop.	-->	
						</xsl:for-each>
					</table>
				<!-- This tag closes the lexicon loop.	-->	
				</xsl:for-each>
			</body>
		</html>
	<!-- close the template -->
	</xsl:template>
<!-- close the stylesheet -->
</xsl:stylesheet>

