<?xml version="1.0" encoding="UTF-8" ?>

<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:hav="http://www.HopAndVineHull.co.uk/Food"
    xmlns:html="http://www.w3.org/1999/xhtml"    
    exclude-result-prefixes="hav html">

  <xsl:template match="/">
    <xsl:apply-templates select="hav:Food"/>
  </xsl:template>

  <xsl:template match="hav:Food">
    <xsl:if test="@Heading">
      <p class="drinksHeading">
        <xsl:value-of select="@Heading"/>
      </p>
    </xsl:if>
    <xsl:apply-templates select="hav:Section"/>
    <br/>
    <div class="drinksFooter">
      <xsl:text>Prices correct at </xsl:text>
      <xsl:value-of select="@ValidFrom"/>
      <xsl:text>. E&amp;OE.</xsl:text>
    </div>
  </xsl:template>

  <xsl:template match="hav:Section">
    <div class="drinksSection">
      
      <xsl:if test="@Icon">
        <span class="drinksIcon">
          <img alt="icon" src="{@Icon}"/>
        </span>
      </xsl:if>
      
      <a id="{translate(@Name, ' ', '_')}" name="{translate(@Name, ' ', '_')}">
        <xsl:value-of select="@Name"/>
        <xsl:text>&#160;</xsl:text>
      </a>
      
    </div>
    
    <xsl:if test="hav:Blurb">
      <div class="drinksBlurb">
        <xsl:apply-templates select="hav:Blurb"/>
      </div>
    </xsl:if>
    <br/>
    
    <xsl:if test="hav:Entry | hav:Juice">
      <table cellspacing="0" cellpadding="0" class="entry">
        <xsl:apply-templates select="hav:Entry | hav:Juice"/>
      </table>
    </xsl:if>
    
  </xsl:template>

  <!-- E N T R Y -->
  <xsl:template match="hav:Entry">
    <tr>
      <td class="entryTitle">
        <b><xsl:value-of select="@Title"/></b>
        <xsl:if test="@SubTitle">
          <xsl:text> </xsl:text>
          <i><xsl:value-of select="@SubTitle"/></i>
        </xsl:if>
        <br/>
        <i>
          <xsl:apply-templates />
        </i>
      </td>
      <td class="entryColumn">
        <xsl:text>£</xsl:text>
        <xsl:value-of select="@Price"/>
      </td>
    </tr>
  </xsl:template>

  <!-- J U I C E -->
  <xsl:template match="hav:Juice">
    <tr>
      <td class="entryTitle">
        <xsl:for-each select="hav:JuiceDetails">
          <span class="entryExtraColumn">
            <xsl:value-of select="@Size"/>
          </span>
          <xsl:if test="position() = 1">
            <b><xsl:value-of select="../@Title"/></b>
          </xsl:if>
          <xsl:if test="position() = last()">
            <i><xsl:value-of select="../text()"/></i>
          </xsl:if>
          <br/>
        </xsl:for-each>
      </td>
      <td class="entryColumn">
        <xsl:for-each select="hav:JuiceDetails">
          <xsl:text>£</xsl:text>
          <xsl:value-of select="@Price"/>
          <br/>
        </xsl:for-each>
      </td>
    </tr>
  </xsl:template>

  <xsl:template match="hav:Blurb">
    <xsl:apply-templates/>
  </xsl:template>

  <xsl:template match="html:*">
    <xsl:element name="{local-name()}">
      <xsl:copy-of select="@*"/>
      <xsl:copy-of select="text()"/>
    </xsl:element>
  </xsl:template>

</xsl:stylesheet>
