<?xml version="1.0" encoding="utf-8"?>

<!-- Start of XSL Transformation. -->

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <xsl:output indent="yes"
              encoding="utf-8"
              method="xml"
              version="1.0"
              doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
              doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
              media-type="text/html"/>

  <!-- We need "cv" root element. -->

  <xsl:template match="/cv">

    <!-- Start. -->

    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="bg" lang="bg">
      <head>
        <link rel="stylesheet" type="text/css" href="css/cv_simple.css" media="all"/>
        <meta http-equiv="content-type" content="text/html; charset=utf-8"/>

        <!-- Insert heading text. -->

        <title>
          <xsl:value-of select="/cv/heading" disable-output-escaping="yes"/>
        </title>

        <!-- Close "head" tag. -->

      </head>

      <!-- Start "body" tag, and body of the XHTML page. -->

      <body>
        <div class="cv">

          <xsl:if test="string-length(/cv/photo)&gt;0">
            <div class="cvPhoto">
              <xsl:text disable-output-escaping="yes"><![CDATA[<img src="]]></xsl:text><xsl:value-of select="/cv/photo" disable-output-escaping="yes"/><xsl:text disable-output-escaping="yes"><![CDATA[" alt="]]></xsl:text><xsl:value-of select="/cv/heading" disable-output-escaping="yes"/><xsl:text disable-output-escaping="yes"><![CDATA["/>]]></xsl:text>
            </div>
          </xsl:if>

          <div class="cvHeading">
            <xsl:value-of select="/cv/heading" disable-output-escaping="yes"/>
          </div>

          <div class="cvContents"><table class="table">

            <!-- Process all CV sections. -->

            <xsl:for-each select="/cv/section">

              <!-- Section heading. -->

              <tr>
                <td class="secName" colspan="2"><xsl:value-of select="@text" disable-output-escaping="yes"/>:</td>
              </tr>

              <!-- Process section fields/values. -->

              <xsl:for-each select="field">
                <tr>
                  <td class="fieldName"><xsl:if test="string-length(@descr) &gt; 0"><xsl:value-of select="@descr" disable-output-escaping="yes"/>:</xsl:if></td>
                  <td class="fieldValue">
                    <div class="cellText">

                      <!-- Search for items with name and value. -->

                      <xsl:choose>

                        <xsl:when test="item">
                          <table class="tableItem">
                            <xsl:for-each select="item">
                              <tr class="trBorder">

                                <td class="tdBorderName">
                                  <span class="tn">
                                    <xsl:value-of select="name"/>
                                  </span>
                                </td>

                                <td class="tdBorderValue">
                                  <xsl:value-of select="value"/>
                                </td>
                              </tr>
                            </xsl:for-each>
                          </table>
                          <br/>
                        </xsl:when>

                        <!-- Search for un-ordered list items. -->

                        <xsl:when test="ul-item">
                          <ul class="ulCustom">
                            <xsl:for-each select="ul-item">
                              <li class="liMarginBottom">
                                <xsl:value-of select="."/>
                              </li>
                            </xsl:for-each>
                          </ul>
                        </xsl:when>

                        <xsl:otherwise>
                          <xsl:value-of select="." disable-output-escaping="yes"/>
                        </xsl:otherwise>

                      </xsl:choose>

                    </div>
                  </td>
                </tr>
              </xsl:for-each>

              <xsl:if test="position() &lt; last()">
                <tr><td><div class="rowSpacer"/></td></tr>
              </xsl:if>

            </xsl:for-each>

            <xsl:for-each select="links/link">
              <tr>
                <td class="fieldName"><xsl:value-of select="@descr" disable-output-escaping="yes"/>:</td>
                <td class="fieldValue">
                  <div class="cellText">
                    <xsl:element name="a">
                      <xsl:attribute name="href"><xsl:value-of select="@href" disable-output-escaping="yes"/></xsl:attribute>
                      <!--<xsl:element name="pre">-->
                        <xsl:value-of select="." disable-output-escaping="yes"/>
                      <!--</xsl:element>-->

                    </xsl:element>
                  </div>
                </td>
              </tr>
            </xsl:for-each>

          </table></div>
        </div>
      </body>
      <!--
          <xsl:text disable-output-escaping="yes"><![CDATA[</html>]]></xsl:text>
      -->
    </html>

  </xsl:template>
</xsl:stylesheet>