<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html [
 <!ENTITY Egrave "&#200;">
 <!ENTITY egrave "&#232;">
 <!ENTITY agrave "&#224;">
 <!ENTITY ugrave "&#249;">
 <!ENTITY nbsp "&#160;">
 <!ENTITY copy "&#0169;">
 <!ENTITY laquo "&#0171;">
 <!ENTITY raquo "&#0187;">
]>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="xml" encoding="utf-8" indent="yes" />

  <xsl:param name="currpage" />
  <xsl:param name="language" />
  <xsl:param name="date" />
  <xsl:param name="render_links">true</xsl:param>
  <xsl:param name="element" />
  <xsl:param name="limit">1000</xsl:param>


<xsl:template match="/">

<xsl:choose>
  <xsl:when test="$element">
       <div class="post">
         <h2 class="title"> <xsl:value-of select="$element"/>: summary</h2>
         <div class="entry">
           <table class="wtable">
           <xsl:for-each select="projects/project[codename=$element]">
             <xsl:apply-templates />
           </xsl:for-each>
           </table>
         </div>
         <xsl:if test="$render_links = 'true'">
          <div class="meta">
            <p class="byline"><xsl:call-template name="render-date"><xsl:with-param name="date" select="$date"/></xsl:call-template>, Alessandro Polo</p>
            <p class="links"><a href="/projects/projects.html?project={$element}" class="comments">versione stampa</a></p>
          </div>
         </xsl:if>
       </div>
  </xsl:when>
  <xsl:otherwise>
    <xsl:apply-templates select="projects | papers" />
  </xsl:otherwise>
</xsl:choose>

</xsl:template>

<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->


<xsl:template match="projects">

<div class="post">

  <xsl:choose>
    <xsl:when test="$language = 'it-IT'">
         <h2 class="title"> progetti</h2>
    </xsl:when>
    <xsl:otherwise>
         <h2 class="title"> projects</h2>
    </xsl:otherwise>
  </xsl:choose>

         <div class="entry">
           <table class="wtable">
            <xsl:for-each select="project[position() &lt; $limit]">
              <xsl:sort select="ranking" data-type="number" order="descending" />
              <xsl:apply-templates />
              <xsl:if test="position() &lt; last()">
                <tr>
                  <td colspan="2"><div class="separator"><xsl:text> </xsl:text></div></td>
                </tr>
              </xsl:if>
             </xsl:for-each>
           </table>
           <xsl:if test="$limit != 1000">
            <br/><p><a href="/projects"><xsl:choose>
            <xsl:when test="$language = 'it-IT'">visualizza tutti i progetti..</xsl:when>
            <xsl:otherwise>see all projects..</xsl:otherwise>
           </xsl:choose></a></p>
           </xsl:if>
         </div>
         <xsl:if test="$render_links = 'true'">
          <div class="meta">
            <p class="byline"><xsl:call-template name="render-date"><xsl:with-param name="date" select="$date"/></xsl:call-template>, Alessandro Polo</p>
<!--            <p class="links"><a href="/projects/projects.html?project={$element}" class="more">versione stampa</a> <b>|</b> <a href="/projects/projects.xml" class="comments">formato XML</a></p>    -->
            <p class="links"><a href="/projects/projects.html" class="more">printer friendly</a> <b>|</b> <a href="/projects/projects.xml" class="comments">XML format</a></p>

          </div>
         </xsl:if>
       </div>

</xsl:template>

<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->


<xsl:template match="papers">

<div class="post">

  <xsl:choose>
    <xsl:when test="$language = 'it-IT'">
         <h2 class="title"> articoli</h2>
    </xsl:when>
    <xsl:otherwise>
         <h2 class="title"> papers</h2>
    </xsl:otherwise>
  </xsl:choose>

         <div class="entry">
           <table class="wtable">
            <xsl:for-each select="paper[position() &lt; $limit]">
              <xsl:sort select="ranking" data-type="number" order="descending" />
              <xsl:apply-templates />
              <xsl:if test="position() &lt; last()">
                <tr>
                  <td colspan="2"><div class="separator"><xsl:text> </xsl:text></div></td>
                </tr>
              </xsl:if>
             </xsl:for-each>
           </table>
           <xsl:if test="$limit != 1000">
            <br/><p><a href="/papers"><xsl:choose>
            <xsl:when test="$language = 'it-IT'">visualizza tutti gli articoli..</xsl:when>
            <xsl:otherwise>see all papers..</xsl:otherwise>
           </xsl:choose></a></p>
           </xsl:if>
         </div>
         <xsl:if test="$render_links = 'true'">
          <div class="meta">
            <p class="byline"><xsl:call-template name="render-date"><xsl:with-param name="date" select="$date"/></xsl:call-template>, Alessandro Polo</p>
<!--            <p class="links"><a href="/projects/projects.html?project={$element}" class="more">versione stampa</a> <b>|</b> <a href="/projects/projects.xml" class="comments">formato XML</a></p>    -->
            <p class="links"><a href="/papers/papers.html" class="more">printer friendly</a> <b>|</b> <a href="/papers/papers.xml" class="comments">XML format</a></p>

          </div>
         </xsl:if>
       </div>

</xsl:template>


 
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->


<xsl:template match="startdate">
      <tr>
        <td class="tblfield"><xsl:choose>
            <xsl:when test="$language = 'it-IT'">Data Inizio:</xsl:when>
            <xsl:otherwise>Start Date:</xsl:otherwise>
        </xsl:choose></td>
        <td class="tbldata"><xsl:call-template name="render-date"><xsl:with-param name="date" select="."/></xsl:call-template></td>
      </tr>
</xsl:template>

<xsl:template match="joindate">
      <tr>
        <td class="tblfield" style="white-space: nowrap;"><xsl:choose>
            <xsl:when test="$language = 'it-IT'">Data Ingresso:</xsl:when>
            <xsl:otherwise>Join Date:</xsl:otherwise>
        </xsl:choose></td>
        <td class="tbldata"><xsl:call-template name="render-date"><xsl:with-param name="date" select="."/></xsl:call-template></td>
      </tr>
</xsl:template>

<xsl:template match="releasedate">
      <tr>
        <td class="tblfield"><xsl:choose>
            <xsl:when test="$language = 'it-IT'">Rilasciato:</xsl:when>
            <xsl:otherwise>Released:</xsl:otherwise>
        </xsl:choose></td>
        <td class="tbldata"><xsl:call-template name="render-date"><xsl:with-param name="date" select="."/></xsl:call-template></td>
      </tr>
</xsl:template>

<xsl:template match="status">
      <tr>
        <td class="tblfield"><xsl:choose>
            <xsl:when test="$language = 'it-IT'">Stato:</xsl:when>
            <xsl:otherwise>Status:</xsl:otherwise>
        </xsl:choose></td>
        <td class="tbldata"><xsl:value-of select="."/></td>
      </tr>
</xsl:template>

<xsl:template match="title">
      <tr>
        <td class="tblfield"><xsl:choose>
            <xsl:when test="$language = 'it-IT'">Titolo:</xsl:when>
            <xsl:otherwise>Title:</xsl:otherwise>
        </xsl:choose></td>
        <td class="tbldata"><xsl:value-of select="."/></td>
      </tr>
</xsl:template>

<xsl:template match="paper/codename">
      <tr>
        <td class="tblfield" style="white-space: nowrap;"><xsl:choose>
            <xsl:when test="$language = 'it-IT'">Nome in Codice:</xsl:when>
            <xsl:otherwise>CodeName:</xsl:otherwise>
        </xsl:choose></td>
        <td class="tbldata"><strong><xsl:value-of select="."/></strong><xsl:if test="$element = ''"> (<a href="/papers/{.}">leggi altro..</a>)</xsl:if></td>
      </tr>
</xsl:template>

<xsl:template match="project/codename">
      <tr>
        <td class="tblfield" style="white-space: nowrap;"><xsl:choose>
            <xsl:when test="$language = 'it-IT'">Nome in Codice:</xsl:when>
            <xsl:otherwise>CodeName:</xsl:otherwise>
        </xsl:choose></td>
        <td class="tbldata"><strong><xsl:value-of select="."/></strong><xsl:if test="$element = ''"> (<a href="/projects/{.}">leggi altro..</a>)</xsl:if></td>
      </tr>
</xsl:template>

<xsl:template match="sector">
      <tr>
        <td class="tblfield"><xsl:choose>
            <xsl:when test="$language = 'it-IT'">Settore:</xsl:when>
            <xsl:otherwise>Sector</xsl:otherwise>
        </xsl:choose></td>
        <td class="tbldata"><xsl:value-of select="."/></td>
      </tr>
</xsl:template>

<xsl:template match="platform">
      <tr>
        <td class="tblfield"><xsl:choose>
            <xsl:when test="$language = 'it-IT'">Piattaforma:</xsl:when>
            <xsl:otherwise>Platform</xsl:otherwise>
        </xsl:choose></td>
        <td class="tbldata"><xsl:value-of select="."/></td>
      </tr>
</xsl:template>

<xsl:template match="employer">
  <xsl:if test="$limit = 1000">
      <tr>
        <td class="tblfield" style="white-space: nowrap;"><xsl:choose>
            <xsl:when test="$language = 'it-IT'">Datore di Lavoro:</xsl:when>
            <xsl:otherwise>Employer:</xsl:otherwise>
        </xsl:choose></td>
        <td class="tbldata"><xsl:value-of select="."/></td>
      </tr>
  </xsl:if>
</xsl:template>

<xsl:template match="position">
      <tr>
        <td class="tblfield"><xsl:choose>
            <xsl:when test="$language = 'it-IT'">Posizione:</xsl:when>
            <xsl:otherwise>Position:</xsl:otherwise>
        </xsl:choose></td>
        <td class="tbldata"><xsl:value-of select="."/></td>
      </tr>
</xsl:template>

<xsl:template match="abstract">
  <xsl:if test="$limit = 1000">
      <tr>
        <td class="tblfield"><xsl:choose>
            <xsl:when test="$language = 'it-IT'">Riassunto:</xsl:when>
            <xsl:otherwise>Abstract:</xsl:otherwise>
        </xsl:choose></td>
        <td class="tbldata"><xsl:call-template name="add-line-breaks"><xsl:with-param name="string" select="."/></xsl:call-template></td>
      </tr>
  </xsl:if>
</xsl:template>

<xsl:template match="links">
 <xsl:if test="$limit = 1000">
  <xsl:if test="count(url) > 0">
   <tr>
    <td class="tblfield"><xsl:choose>
            <xsl:when test="$language = 'it-IT'">Riferimenti:</xsl:when>
            <xsl:otherwise>Links:</xsl:otherwise>
        </xsl:choose></td>
    <td class="tbldata">
      <ul class="compact">
       <xsl:for-each select="url">
         <li><a href="{.}" title="{@name}"><xsl:value-of select="."/></a></li>
       </xsl:for-each>
      </ul>
    </td>
   </tr>
  </xsl:if>
 </xsl:if>
</xsl:template>

<xsl:template match="tags">
 <xsl:if test="$limit = 1000">
  <xsl:if test="count(tag) > 0">
   <tr>
    <td class="tblfield">Tags:</td>
    <td class="tbldata"><span>
      <xsl:for-each select="tag">
       <a href="/tags/{.}"><xsl:value-of select="."/></a>
       <xsl:if test="position() &lt; last()">
         <xsl:text>, </xsl:text>
       </xsl:if>
      </xsl:for-each>
    </span></td>
   </tr>
  </xsl:if>
 </xsl:if>
</xsl:template>

<xsl:template match="keywords | ranking">
</xsl:template>

<xsl:template match="language">
      <tr>
        <td class="tblfield"><xsl:choose>
            <xsl:when test="$language = 'it-IT'">Lingua:</xsl:when>
            <xsl:otherwise>Language:</xsl:otherwise>
        </xsl:choose></td>
        <td class="tbldata"><img src="/_images/locale.{.}.gif" alt="{.}" /><xsl:text> </xsl:text><xsl:value-of select="."/></td>
      </tr>
</xsl:template>




<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->


<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->

<xsl:template name="render-date">
   <xsl:param name="date" />

   <xsl:if test="not (substring($date, 9, 1) = '0')">
    <xsl:value-of select="substring($date, 9, 1)" />
   </xsl:if>
   <xsl:value-of select="substring($date, 10, 1)" />
   <xsl:text> </xsl:text>

  <xsl:choose>
    <xsl:when test="$language = 'it-IT'">
      <xsl:choose>
        <xsl:when test="substring($date, 6, 2) = '01'">Gennaio</xsl:when>
        <xsl:when test="substring($date, 6, 2) = '02'">Febbraio</xsl:when>
        <xsl:when test="substring($date, 6, 2) = '03'">Marzo</xsl:when>
        <xsl:when test="substring($date, 6, 2) = '04'">Aprile</xsl:when>
        <xsl:when test="substring($date, 6, 2) = '05'">Maggio</xsl:when>
        <xsl:when test="substring($date, 6, 2) = '06'">Giugno</xsl:when>
        <xsl:when test="substring($date, 6, 2) = '07'">Luglio</xsl:when>
        <xsl:when test="substring($date, 6, 2) = '08'">Agosto</xsl:when>
        <xsl:when test="substring($date, 6, 2) = '09'">Settembre</xsl:when>
        <xsl:when test="substring($date, 6, 2) = '10'">Ottobre</xsl:when>
        <xsl:when test="substring($date, 6, 2) = '11'">Novembre</xsl:when>
        <xsl:when test="substring($date, 6, 2) = '12'">Dicembre</xsl:when>
      </xsl:choose>
    </xsl:when>
    <xsl:otherwise>
      <xsl:choose>
        <xsl:when test="substring($date, 6, 2) = '01'">January</xsl:when>
        <xsl:when test="substring($date, 6, 2) = '02'">February</xsl:when>
        <xsl:when test="substring($date, 6, 2) = '03'">March</xsl:when>
        <xsl:when test="substring($date, 6, 2) = '04'">April</xsl:when>
        <xsl:when test="substring($date, 6, 2) = '05'">May</xsl:when>
        <xsl:when test="substring($date, 6, 2) = '06'">June</xsl:when>
        <xsl:when test="substring($date, 6, 2) = '07'">July</xsl:when>
        <xsl:when test="substring($date, 6, 2) = '08'">August</xsl:when>
        <xsl:when test="substring($date, 6, 2) = '09'">September</xsl:when>
        <xsl:when test="substring($date, 6, 2) = '10'">October</xsl:when>
        <xsl:when test="substring($date, 6, 2) = '11'">November</xsl:when>
        <xsl:when test="substring($date, 6, 2) = '12'">December</xsl:when>
      </xsl:choose>
    </xsl:otherwise>
   </xsl:choose>

   <xsl:text> </xsl:text>
   <xsl:value-of select="substring($date, 1, 4)" />

</xsl:template>

<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->


<xsl:template name="add-line-breaks">
   <xsl:param name="string" />

   <xsl:choose>
      <xsl:when test="contains($string, '&#xD;')">
         <xsl:value-of select="substring-before($string, '&#xD;')" />
         <br />
         <xsl:call-template name="add-line-breaks">
            <xsl:with-param name="string"
                            select="substring-after($string, '&#xD;')" />
         </xsl:call-template>
      </xsl:when>
      <xsl:otherwise>
         <xsl:value-of select="$string" />
      </xsl:otherwise>
   </xsl:choose>
</xsl:template>

<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->

<xsl:template match="anchor">
  <a name="{.}">&nbsp;<xsl:text> </xsl:text></a>
</xsl:template>


<xsl:template match="para">

  <xsl:element name="p">
    <xsl:for-each select="@*">
      <xsl:attribute name="{name()}"><xsl:value-of select="."/></xsl:attribute>
    </xsl:for-each>
    <xsl:apply-templates/>
  </xsl:element>

</xsl:template>



<xsl:template match="unorderedlist">
  <ul>
    <xsl:for-each select="listitem">
       <li><xsl:apply-templates /></li>
    </xsl:for-each>
  </ul>
</xsl:template>

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


<xsl:template match="@*|a|img|br|i|em" priority="-1">
  <xsl:copy><xsl:apply-templates select="@*|node()"/></xsl:copy>
</xsl:template>


</xsl:stylesheet>

