<?xml version="1.0"  encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:import href="resultset_html.xsl" />
<xml:output method="text"/>
<xsl:strip-space elements="*" /> 
<xsl:template match="/">

<xsl:if test="/ergebnisse/makro/@id !=''">
<xsl:value-of select="/ergebnisse/makro/name" /><xsl:text>

</xsl:text>
</xsl:if>

<xsl:for-each select="ergebnisse/ergebnis/ergebniselement">
<xsl:choose>
<xsl:when test="@typ='tabelle'">
<xsl:value-of select="../maskenname" />
<xsl:text>
</xsl:text>

<xsl:for-each select="../felder/feld">
	<xsl:if test="value !=''  and @varname != 'sort' and @varname != 'maxoffset'">
<xsl:choose>
		<xsl:when test="string-length(caption_short) &gt; 0 and caption_short != 'null'" >
		<xsl:value-of select="caption_short" />
		</xsl:when>
		<xsl:otherwise>
		<xsl:value-of select="@varname" />
		</xsl:otherwise>
		</xsl:choose>: <xsl:if test="string-length(value_caption) &lt; 50">
			<xsl:value-of select="value_caption" />
		</xsl:if>
		<xsl:if test="string-length(value_caption) &gt; 49">
			<xsl:value-of select="substring(value_caption,0,50)" />...
		</xsl:if>
		<xsl:text>; 
</xsl:text>
		</xsl:if>
</xsl:for-each>
<xsl:text>
Stand: </xsl:text><xsl:value-of select="../stand" /><xsl:text>
</xsl:text>


<xsl:for-each select="sqlerg/headers/header">
<xsl:call-template name="remove_linebreaks">
  <xsl:with-param name="volltext" select="wert" />
  </xsl:call-template><xsl:text> </xsl:text>
</xsl:for-each><xsl:text>
</xsl:text>
<xsl:for-each select="sqlerg/row">
<xsl:for-each select="col">
 	<xsl:choose>
		<xsl:when test="starts-with(f_name,'next')">
	<xsl:text> </xsl:text>
			</xsl:when>
		
		<xsl:otherwise>
        		<xsl:call-template name="remove_linebreaks">
  <xsl:with-param name="volltext" select="wert" />
  </xsl:call-template><xsl:text> </xsl:text>

		</xsl:otherwise>
	</xsl:choose>
</xsl:for-each>
<xsl:text>
</xsl:text>

</xsl:for-each>
<xsl:text>
</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>
Nicht unterstuetzter Ergebnistyp </xsl:text><xsl:value-of select="@type" />
</xsl:otherwise>
</xsl:choose>
<xsl:call-template name="datensatzzaehler" />

</xsl:for-each>

</xsl:template>
<xsl:template name="remove_linebreaks">
  <xsl:param name="volltext" />
  <xsl:choose>
<xsl:when test="contains($volltext,'\n')">
<xsl:value-of select="substring-before($volltext,'\n')"/><xsl:text> </xsl:text>
<xsl:call-template name="remove_linebreaks">
<xsl:with-param name="volltext"><xsl:value-of select="substring-after($volltext,'\n')" /> 
</xsl:with-param>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="$volltext" />
</xsl:otherwise>
</xsl:choose>    
   
  </xsl:template>
</xsl:stylesheet>