<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:mmax="pl.waw.ipipan.zil.core.mmax4ref.discourse.MMAX2DiscourseLoader" xmlns:mention="www.eml.org/NameSpaces/mention">

<xsl:output method="text" indent="no" omit-xml-declaration="yes"/>
<xsl:strip-space elements="*"/>

<xsl:template match="words">
	<xsl:text>
</xsl:text>
	<xsl:apply-templates/>
</xsl:template>

<xsl:template match="word">
	<xsl:value-of select="mmax:registerDiscourseElement(@id)"/>
	<xsl:apply-templates select="mmax:getStartedMarkables(@id)" mode="opening"/>
	<xsl:value-of select="mmax:setDiscourseElementStart()"/>
	<xsl:apply-templates/>
	<xsl:value-of select="mmax:setDiscourseElementEnd()"/>
	<xsl:apply-templates select="mmax:getEndedMarkables(@id)" mode="closing"/>
	<xsl:text> </xsl:text>
	<xsl:choose>
		<xsl:when test="@lastinpar='true'">
<xsl:text>
 	
</xsl:text>
		</xsl:when>
	</xsl:choose>
</xsl:template>

<xsl:template match="mention:markable" mode="opening">
	<xsl:value-of select="mmax:addLeftMarkableHandle(@mmax_level, @id, '[')"/>
</xsl:template>

<xsl:template match="mention:markable" mode="closing">
	<xsl:value-of select="mmax:addRightMarkableHandle(@mmax_level, @id, ']')"/>
</xsl:template>

</xsl:stylesheet>
