<?xml version="1.0" encoding="utf-8"?>

<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:include href="text-tos.xsl"/>
	<!--Шаблон для корневого элемента-->
	<xsl:template match="/">
		
			<xsl:apply-templates select="question-out"/>
		
	</xsl:template>
	<!-- шаблон для вопроса-->
	<xsl:template match="question-out">
		<xsl:choose>
			<xsl:when test="descendant::answ-output[@type='single' or @type='check']">
				<xsl:for-each select="descendant::answ-output[@right='1']">
					<xsl:if test="position()>1">
						<xsl:text>, </xsl:text>
					</xsl:if>
					<xsl:choose>
						<xsl:when test="@number&lt;=26">
							<xsl:value-of select="substring('abcdefghijklmnopqrstuvwxyz',@number,1)"/>
						</xsl:when>
						<xsl:otherwise>
							<xsl:choose>
								<xsl:when test="(@number mod 26)=0">
									<xsl:value-of select="substring('abcdefghijklmnopqrstuvwxyz',floor(@number div 26)-1,1)"/>
									<xsl:value-of select="substring('abcdefghijklmnopqrstuvwxyz',26,1)"/>
								</xsl:when>
								<xsl:otherwise>
									<xsl:value-of select="substring('abcdefghijklmnopqrstuvwxyz',floor(@number div 26),1)"/>
									<xsl:value-of select="substring('abcdefghijklmnopqrstuvwxyz',@number mod 26,1)"/>
								</xsl:otherwise>
							</xsl:choose>
						</xsl:otherwise>
					</xsl:choose>
				</xsl:for-each>
			</xsl:when>
			<xsl:otherwise>
				<xsl:for-each select="descendant::answ-output">
					<xsl:if test="position()>1">
						<xsl:text>, </xsl:text>
					</xsl:if>
					<xsl:value-of select="@right"/>
				</xsl:for-each>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	

	
	
</xsl:stylesheet>
