<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">

 <xsl:output method="html" encoding="UTF-8"/>
  <xsl:template name="nl2br">
   <xsl:param name="contents" />
   <xsl:choose>
    <xsl:when test="contains($contents, '&#10;')">
    <xsl:value-of select="substring-before($contents, '&#10;')" />
    <br />
    <xsl:call-template name="nl2br">
     <xsl:with-param name="contents" select="substring-after($contents, '&#10;')" />
    </xsl:call-template>
   </xsl:when>
   <xsl:otherwise>
    <xsl:value-of select="$contents" />
   </xsl:otherwise>
  </xsl:choose>
 </xsl:template>
 
 <xsl:template match="return">
 <html>
  <head>
   <title>Suchergebnis</title>
  </head>
  <body>
   <p>Ergebnis</p>
   <p>Treffer insgesamt: <b><xsl:value-of select="estimatedTotalResultsCount"/></b></p>
   <p>Treffer ( <xsl:value-of select="startIndex"/> bis <xsl:value-of select="endIndex"/> )</p>
   <form action="client.php">
   <input type="hidden" name="demo" value="3"/>
   <input type="hidden" name="tag" value="arbeitsplatz24"/>
   <input type="hidden" name="limit" value="20"/>
   <input type="hidden" name="group" value="1"/>
   <input type="text" name="q" value=""><xsl:attribute name="value"><xsl:value-of select="searchQuery" /></xsl:attribute></input>
   <input type="submit" value="suchen"/>
   </form>
   <table>
    <tr><!--<th>JobID</th>--><th>Title</th><th>Einsatzort</th><th>Sprache</th><th>Datum</th></tr>

    <xsl:for-each select="resultElements/item">
     <tr>
      <!--<td><xsl:value-of select="jobId"/></td>-->
      <td><a><xsl:attribute name="href"><xsl:value-of select="URL" /></xsl:attribute><xsl:value-of select="title"/></a></td>
      <td><xsl:value-of select="jobLocation"/></td>
      <td><xsl:value-of select="jobLanguage"/></td>
      <td><xsl:value-of select="date"/></td>
     </tr>
    </xsl:for-each>
   <tr>
     <xsl:variable name="startIndex" select="startIndex"/>
     <xsl:variable name="endIndex" select="endIndex"/>
     <xsl:variable name="totalResultsCount" select="estimatedTotalResultsCount"/>
     <xsl:variable name="limit">20</xsl:variable>
     <td>
       <xsl:choose>
         <xsl:when test="$startIndex >= $limit ">
           <a><xsl:attribute name="href">?demo=3&amp;start=<xsl:value-of select="number($startIndex - 21)"/></xsl:attribute>back</a>
         </xsl:when>
       </xsl:choose>
     </td>
     <td colspan="2"></td>
     <td>
       <xsl:choose>
         <xsl:when test="number($totalResultsCount - $startIndex - $limit) >= 0">
           <a><xsl:attribute name="href">?query=<xsl:value-of select="searchQuery" />&amp;demo=3&amp;start=<xsl:value-of select="endIndex" /></xsl:attribute>next</a>
         </xsl:when>
       </xsl:choose>
     </td>
   </tr>
   </table>
  </body>
 </html>
 </xsl:template>
</xsl:stylesheet>
