<!--

By: Tomoko Okuno
Summer 2003
To: output a word list 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">

<!--
 This stylesheet outputs xhtml (which is a dialect of xml) in unicode. In fact, this line puts the xhtml strict doctype into the output file, namely <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
-->

<xsl:output method="xml" encoding="utf-8" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" indent="yes" omit-xml-declaration="yes" media-type="application/xhtml+xml" />
	<!--
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 insert the html tags we want in the output. 
		-->
		<html>
			<head>
				<title>Biao Mien 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 is a loop. This tag tells the parser, each time you encounter a "lexicon" tag, do everything contained in the xsl:for-each tag. 
				-->
				<xsl:for-each select="lexicon">
					<!-- insert html tags in output -->
					<br/>
					<span style="font-family:Arial Unicode MS;font-size:large; color:#666699; ">Biao Min</span>&#160;			
					<!-- This is a loop.   The @ symbol means 'attribute'  This tells the parser, each time you encounter an "lang" attribute (of the lexicon element)  in the xml file, do what is contained in the :xsl for-each tag.  -->
                    <xsl:for-each select="@lang">
						<span style="font-family:Arial Unicode MS;color:#666699;">
							<span style="font-family:Arial Unicode MS; ">&#40;</span>
							<!--  Output the value of the current node.  Since we are currently in the lang attribute, the information contained in it will be output. -->
							<xsl:value-of select="."/>
							<span style="font-family:Arial Unicode MS; ">&#41;</span>
						</span>
					<!-- This closes the lang loop-->
					</xsl:for-each>
					<!-- more html -->
					<br/>
					<span style="font-family:Arial Unicode MS;font-size:small;color:#666699;">
						<b>Field Linguist:</b>
					</span>
					<!-- For each linguist attribute, -->
					<xsl:for-each select="@linguist">
						<span style="font-family:Arial Unicode MS;color:#666699; ">
							<!-- output its value -->
							<xsl:value-of select="."/>
						</span>
					<!-- close the linguist loop -->
					</xsl:for-each>
					<br/><br/>
					<span style="font-family:Arial Unicode MS;color:#0033ff;font-size:10; ">
						Note: These demonstration sound files are not by a native speaker of Biao Min.
					</span>
					<!-- For each forms element, -->
					<xsl:for-each select="forms">
						<!-- For each form element, -->
						<xsl:for-each select="form">
							<!-- if there lang attribute equals Biao-jiao Mien than do what is contained in 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; ">
											<!--Output the value of the current node. We are currently in the "unanalyzedform" node, this will output its value. -->
											<xsl:value-of select="."/>
										</span>
									<!-- close the unanalyzedform loop -->
									</xsl:for-each>
								<!-- close 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>
								<!-- We have stepped back out, so the current node is the form element. For each id attribute of the form element, -->
																			
								<xsl:for-each select="@id">
								<!-- Output html tag. The '.' contained within curly brackets inserts the value of the attribute into the  html href tag -->
									<a href="sound/mp3/{.}.mp3">
										<img src="audio.gif" border="0"/>
									</a>
								<!-- close the id loop -->
								</xsl:for-each>
								<span style="font-family:Arial Unicode MS; ">&#160;</span>
								<!-- Each time you encounter a grammatical-relation element, do what is contained within the tags. -->
								<xsl:for-each select="grammatical-relation">
									<!--The xsl:choose element is used in  with xsl:when and xsl:otherwise to express multiple conditional tests. -->
									<xsl:choose>
										<!-- When the pos attribute of the grammatical-relation element is equal to Noun, -->
										<xsl:when test="@pos='Noun'">
											<!-- For each pos attribute,  -->
											<xsl:for-each select="@pos">
												<!-- insert a small n -->
												<span style="font-family:Arial Unicode MS;color:#666699; font-style:italic;  ">
													<small>n</small>
												</span>
											<!-- close pos loop -->
											</xsl:for-each>
										<!-- close noun when -->
										</xsl:when>
										<!-- When the pos attribute is equal to verb, -->
										<xsl:when test="@pos='Verb'">
											<!-- for each pos attribute, -->
											<xsl:for-each select="@pos">
												<!-- insert a small v -->
												<span style="font-family:Arial Unicode MS;color:#666699; font-style:italic;  ">
													<small>v</small>
												</span>
											<!-- close pos loop -->
											</xsl:for-each>
										<!-- close verb when -->
										</xsl:when>
										<!-- When the pos attribute is equal to a numberal -->
										<xsl:when test="@pos='Numeral'">
											<!-- for each pos attribute, -->
											<xsl:for-each select="@pos">
												<!-- insert a small 'num' -->
												<span style="font-family:Arial Unicode MS;color:#666699; font-style:italic;  ">
													<small>num</small>
												</span>
											<!-- close pos loop -->
											</xsl:for-each>
										<!-- close numeral when -->
										</xsl:when>
										<!-- If none of the when conditions apply, than do what is contained in the otherwise tag (which is nothing)  You could also output some sort of flag that says none of the when conditions applied... -->
										<xsl:otherwise>
												
										</xsl:otherwise>
									<!-- close the choose tag -->
									</xsl:choose>
								<!-- close the grammatical relation loop -->
								</xsl:for-each>
								<span style="font-family:Arial Unicode MS; ">&#160;</span>
								<span style="font-family:Arial Unicode MS; ">&#160;</span>
								<!-- Loop through the gloss elements,  -->
								<xsl:for-each select="gloss">
									<!-- if the lang attribute of the gloss is English, -->
									<xsl:if test="@lang='English'">
										<!-- loop through the value attributes, -->
										<xsl:for-each select="@value">
											<span style="font-family:Arial Unicode MS;color:#666699; ">												<!-- output the value attribute -->
												<xsl:value-of select="."/>
											</span>
										<!-- close value loop -->
										</xsl:for-each>
									<!-- close language if statement -->
									</xsl:if>
								<!-- close gloss 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;color:#666699; ">&#160;</span>
								<!-- We have stepped back out, so the current node is the form element. For each id attribute of the form element, -->
								<xsl:for-each select="@id">
									<!-- The '.' contained within curly brackets inserts the value of the attribute inot the  html href tag -->
									<a href="{.}.html" target="_blank">
										<span style="font-family:Arial Unicode MS;font-size:12; color:#666699;">
											More</span>
									</a>
								<!-- close the id loop -->
								</xsl:for-each>
							<!-- close the lang if tag-->
							</xsl:if>
						<!-- close the form loop -->
						</xsl:for-each>
					<!-- close the forms loop -->
					</xsl:for-each>
				<!-- close the lexicon loop -->
				</xsl:for-each>
			</body>
		</html>
	<!-- close the template -->
	</xsl:template>
<!-- end of stylesheet -->
</xsl:stylesheet>
