<?xml version="1.0"?>
<xsl:stylesheet version="2.0" xmlns="http://www.w3.org/1999/xhtml" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink">



	<xsl:include href="definition.xsl"/>

	<xsl:include href="proposition.xsl"/>

	<xsl:output method="xml"/>



	<xsl:template match="comment()">
		<h2 align="center">
			<xsl:number count="comment()" level="single" format="I. "/>
			<xsl:value-of select="."/>
		</h2>
	</xsl:template>


	<xsl:template match="conceptObject">

		<xsl:choose>
			<xsl:when test="not(parent::argument) and not(parent::reference)">


				<xsl:call-template name="conceptObject"/>
			</xsl:when>
			<xsl:otherwise>
				<xsl:call-template name="conceptObject"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

	<xsl:template name="conceptObject">

		<xsl:choose>
			<xsl:when test="./vocabulary/normalize-space(node())='equal'">
				<xsl:for-each select="./argument/*[not(position()=last())]">
					<xsl:apply-templates select="."/>

					<xsl:text> &#x2261; </xsl:text>
				</xsl:for-each>
				<xsl:apply-templates select="./argument/*[position()=last()]"/>
			</xsl:when>
			<xsl:when test="./vocabulary/normalize-space(node())='greater'">
				<xsl:for-each select="./argument/*[1]">
					<xsl:apply-templates select="."/>

					<xsl:text>&gt;</xsl:text>
				</xsl:for-each>
				<xsl:apply-templates select="./argument/*[2]"/>
			</xsl:when>
			<xsl:when test="./vocabulary/normalize-space(node())='less'">
				<xsl:for-each select="./argument/*[1]">
					<xsl:apply-templates select="."/>
					<xsl:text>&lt;</xsl:text>
				</xsl:for-each>
				<xsl:apply-templates select="./argument/*[2]"/>
			</xsl:when>
			<xsl:otherwise>
				<xsl:apply-templates select="./*"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

	<xsl:template match="vocabulary">
		<a class="concept">
			<xsl:if test="parent::conceptObject/@reference and not(parent::conceptObject/@reference='null')">
				<xsl:attribute name="href">
					<xsl:value-of select="parent::conceptObject/@reference"/>
				</xsl:attribute>
				<!--xsl:attribute name="target">_blank</xsl:attribute-->
			</xsl:if>
			<xsl:value-of select="."/>
		</a>
	</xsl:template>

	<xsl:template match="argument">
		<xsl:text>(</xsl:text>
		<xsl:for-each select="./*[not(position()=last())]">
			<xsl:apply-templates select="."/>
			<xsl:text>,</xsl:text>
		</xsl:for-each>
		<xsl:apply-templates select="./*[position()=last()]"/>
		<xsl:text>)</xsl:text>
	</xsl:template>



	<xsl:template match="pointer">
		<xsl:choose>
			<xsl:when test="parent::return or parent::binding or parent::list">
				<math:math>
					<xsl:call-template name="pointerwithtype"/>
					<xsl:text> </xsl:text>
				</math:math>
			</xsl:when>
			<xsl:otherwise>
				<math:math>
					<xsl:call-template name="pointerwithouttype"/>
				</math:math>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

	<xsl:template name="pointerwithtype">
		<xsl:choose>
			<xsl:when test="contains(normalize-space(.),'_')">
				<math:msub>
					<math:mi>
						<xsl:value-of select="substring-before(normalize-space(.),'_')"/>
					</math:mi>
					<math:mfenced open="" close="" separator=",">
						<math:mi>
							<xsl:value-of select="substring-after(normalize-space(.),'_')"/>
						</math:mi>
					</math:mfenced>
				</math:msub>
			</xsl:when>
			<xsl:otherwise>
				<math:mi>
					<xsl:value-of select="."/>
				</math:mi>
			</xsl:otherwise>
		</xsl:choose>
		<xsl:if test="@type">
			<math:mtext>
				<xsl:text>::</xsl:text>
				<xsl:value-of select="@type"/>
			</math:mtext>
		</xsl:if>
	</xsl:template>


	<xsl:template name="pointerwithouttype">
		<xsl:choose>
			<xsl:when test="contains(normalize-space(.),'_')">
				<math:msub>
					<math:mi>
						<xsl:value-of select="substring-before(normalize-space(.),'_')"/>
					</math:mi>
					<math:mfenced open="" close="" separator=",">
						<math:mi>
							<xsl:value-of select="substring-after(normalize-space(.),'_')"/>
						</math:mi>
					</math:mfenced>
				</math:msub>
			</xsl:when>
			<xsl:otherwise>
				<math:mi>
					<xsl:value-of select="."/>
				</math:mi>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

	<xsl:template match="quantity">
		<math:math>
			<xsl:choose>
				<xsl:when test="@type='number'">
					<math:mn>
						<xsl:value-of select="normalize-space(.)"/>
					</math:mn>
				</xsl:when>
				<xsl:otherwise>
					<math:mi>
						<xsl:value-of select="normalize-space(.)"/>
					</math:mi>
				</xsl:otherwise>
			</xsl:choose>
			<xsl:if test="@type">
				<math:mtext>
					<xsl:text>::</xsl:text>
					<xsl:value-of select="@type"/>
				</math:mtext>
			</xsl:if>
		</math:math>
	</xsl:template>



	<xsl:template match="binding">
		<xsl:text>[</xsl:text>
		<xsl:apply-templates/>
		<xsl:text>]</xsl:text>
	</xsl:template>



	<xsl:template match="return">
		<xsl:text> &#x225C; </xsl:text>
		<xsl:choose>
			<xsl:when test="not(./*)">&#x22A5;</xsl:when>
			<xsl:otherwise>
				<xsl:apply-templates select="./*"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>



	<xsl:template match="list">
		<xsl:choose>
			<xsl:when test="not(parent::reference)">
				<xsl:text>{</xsl:text>
				<xsl:for-each select="./*[not(position()=last())]">
					<xsl:apply-templates select="."/>
					<xsl:text>; </xsl:text>
				</xsl:for-each>
				<xsl:apply-templates select="./*[position()=last()]"/>
				<xsl:text>}</xsl:text>
			</xsl:when>
			<xsl:otherwise>
				<xsl:call-template name="list"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

	<xsl:template name="list">
		<xsl:text>{</xsl:text>
		<xsl:for-each select="./*[not(position()=last())]">
			<xsl:apply-templates select="."/>
			<xsl:text>; </xsl:text>
		</xsl:for-each>
		<xsl:apply-templates select="./*[position()=last()]"/>
		<xsl:text>}</xsl:text>
	</xsl:template>

	<xsl:template match="set">
		<xsl:value-of select="@name"/>
		<xsl:text>(</xsl:text>
		<xsl:for-each select="./*[not(position()=last())]">
			<xsl:apply-templates select="."/>
			<xsl:text>,</xsl:text>
		</xsl:for-each>
		<xsl:apply-templates select="./*[position()=last()]"/>
		<xsl:text>)</xsl:text>
	</xsl:template>


	<xsl:template match="property">
		<xsl:if test="./*">
			<p>
				<b>
					<xsl:text>Property:</xsl:text>
				</b>
				<xsl:apply-templates/>
			</p>
		</xsl:if>
	</xsl:template>


	<xsl:template match="not">
		<xsl:choose>
			<xsl:when test="not(parent::and) and not(parent::or)">
				<xsl:call-template name="not"/>
			</xsl:when>
			<xsl:otherwise>
				<xsl:call-template name="not"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

	<xsl:template name="not">
		<xsl:text>&#xAC;</xsl:text>
		<xsl:text>(</xsl:text>
		<xsl:apply-templates select="./*"/>
		<xsl:text>)</xsl:text>
	</xsl:template>

	<xsl:template match="is">
		<xsl:apply-templates select="./*[1]"/>
		<b>is</b>
		<xsl:apply-templates select="./*[2]"/>
	</xsl:template>

	<xsl:template match="imply">
		<xsl:apply-templates select="./*[1]"/>&#x22A2;   <xsl:apply-templates select="./*[2]"/></xsl:template>


	<xsl:template match="reference">
		<xsl:apply-templates select="./*[1]"/>
		<xsl:text>:=</xsl:text>
		<xsl:apply-templates select="./*[2]"/>
	</xsl:template>

	<xsl:template match="configuration">
		<xsl:for-each select="./*">
			<xsl:apply-templates select="."/>
			<xsl:if test="not(name()='configuration')">
				<xsl:text>; </xsl:text>
			</xsl:if>
		</xsl:for-each>
	</xsl:template>

	<xsl:template match="quantityFunction">
		<xsl:choose>
			<xsl:when test="@name='times'">
				<xsl:for-each select="./*[not(position()=last())]">
					<xsl:apply-templates select="."/>*</xsl:for-each>
				<xsl:apply-templates select="./*[position()=last()]"/>
			</xsl:when>
			<xsl:when test="@name='plus'">
				<xsl:for-each select="./*[not(position()=last())]">
					<xsl:apply-templates select="."/>+</xsl:for-each>
				<xsl:apply-templates select="./*[position()=last()]"/>
			</xsl:when>
			<xsl:when test="@name='minus'">
				<xsl:text>(</xsl:text>
				<xsl:for-each select="./*[not(position()=last())]">
					<xsl:apply-templates select="."/>-</xsl:for-each>
				<xsl:apply-templates select="./*[position()=last()]"/>
				<xsl:text>)</xsl:text>
			</xsl:when>
			<xsl:when test="@name='divide'">
				<xsl:text>(</xsl:text>
				<xsl:for-each select="./*[not(position()=last())]">
					<xsl:apply-templates select="."/>/</xsl:for-each>
				<xsl:apply-templates select="./*[position()=last()]"/>
				<xsl:text>)</xsl:text>
			</xsl:when>
			<xsl:otherwise>
				<xsl:value-of select="@name"/>
				<xsl:text>(</xsl:text>
				<xsl:for-each select="./*[not(position()=last())]">
					<xsl:apply-templates select="."/>,</xsl:for-each>
				<xsl:apply-templates select="./*[position()=last()]"/>
				<xsl:text>)</xsl:text>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
</xsl:stylesheet><!-- Stylus Studio meta-information - (c) 2004-2007. Progress Software Corporation. 保留所有权力.
<metaInformation>
<scenarios/><MapperMetaTag><MapperInfo srcSchemaPathIsRelative="yes" srcSchemaInterpretAsXML="no" destSchemaPath="" destSchemaRoot="" destSchemaPathIsRelative="yes" destSchemaInterpretAsXML="no"/><MapperBlockPosition></MapperBlockPosition><TemplateContext></TemplateContext><MapperFilter side="source"></MapperFilter></MapperMetaTag>
</metaInformation>
-->