<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
  xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0"
  xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0"
  xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0"
  xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0"
  xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"
  xmlns:xlink="http://www.w3.org/1999/xlink"
  xmlns:dc="http://purl.org/dc/elements/1.1/"
  xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0"
  xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0"
  xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"
  xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0"
  xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0"
  xmlns:math="http://www.w3.org/1998/Math/MathML"
  xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0"
  xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0"
  xmlns:ooo="http://openoffice.org/2004/office"
  xmlns:ooow="http://openoffice.org/2004/writer"
  xmlns:oooc="http://openoffice.org/2004/calc"
  xmlns:dom="http://www.w3.org/2001/xml-events"
  xmlns:xforms="http://www.w3.org/2002/xforms"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  version="2.0">


  <xsl:output
    method="xml"
    indent="yes"/>


  <xsl:param name="fonts">
    <open-office>
      <style:font-face
        style:name="Eterna"
        svg:font-family="Eterna"
        style:font-pitch="variable"/>
      
      <style:font-face
        style:name="Garamand Classic"
        svg:font-family="&apos;Garamand Classic&apos;"
        style:font-pitch="variable"/>
      
      <style:font-face
        style:name="Gazette"
        svg:font-family="Gazette"
        style:font-pitch="variable"/>
      
      <style:font-face
        style:name="Kane"
        svg:font-family="Kane"
        style:font-pitch="variable"/>
      
      <style:font-face
        style:name="Top Hat"
        svg:font-family="&apos;Top Hat&apos;"
        style:font-pitch="variable"/>
      
      <style:font-face
        style:name="ProseAntique"
        svg:font-family="ProseAntique"
        style:font-family-generic="script"
        style:font-pitch="variable"/>

      <style:font-face
        style:name="Papyrus"
        svg:font-family="AncientScript"
        style:font-family-generic="script"
        style:font-pitch="variable"/>
    </open-office>

    <microsoft>
      <style:font-face
        style:name="Eterna"
        svg:font-family="Palatino Linotype"
        style:font-pitch="variable"/>
      
      <style:font-face
        style:name="Garamand Classic"
        svg:font-family="Palatino Linotype"
        style:font-pitch="variable"/>
      
      <style:font-face
        style:name="Gazette"
        svg:font-family="Maiandra GD"
        style:font-pitch="variable"/>
      
      <style:font-face
        style:name="Kane"
        svg:font-family="Maiandra GD"
        style:font-pitch="variable"/>
      
      <style:font-face
        style:name="Top Hat"
        svg:font-family="Tempus Sans ITC"
        style:font-pitch="variable"/>
      
      <style:font-face
        style:name="ProseAntique"
        svg:font-family="Felix Titling"
        style:font-family-generic="script"
        style:font-pitch="variable"/>

    <style:font-face
        style:name="Papyrus"
        svg:font-family="Papyrus"
        style:font-family-generic="script"
        style:font-pitch="variable"/>
    </microsoft>
  </xsl:param>
  

  <!-- the fo:font-weight=bold is a microsoft compatibility artifact -->
  <xsl:param name="styles">
    <style:style style:name="Main-Name"
      style:family="paragraph"
      style:parent-style-name="Standard">
      <style:paragraph-properties
        fo:text-align="center"
        style:justify-single-word="false"/>
      <style:text-properties
        style:font-name="ProseAntique"
        fo:font-size="16pt"
        fo:font-weight="bold"
        style:font-size-asian="16pt"
        style:font-size-complex="16pt"/>
    </style:style>
    
    <style:style
      style:name="Main-Address"
      style:family="paragraph"
      style:parent-style-name="Standard">
      <style:paragraph-properties
        fo:text-align="center"
        style:justify-single-word="false"/>
      <style:text-properties
        style:font-name="Eterna"/>
    </style:style>
    
    <style:style
      style:name="Heading-Big"
      style:family="paragraph"
      style:parent-style-name="Standard">
      <style:paragraph-properties
        fo:text-align="start"
        fo:margin-top="0.3cm"
        style:justify-single-word="false">
        <style:tab-stops>
          <style:tab-stop style:position="17cm"
            style:type="right"
            style:leader-style="dash"
            style:leader-type="single"
            style:leader-width="thin"
            />
        </style:tab-stops>
      </style:paragraph-properties>
      <style:text-properties
        style:font-name="Kane"
        fo:font-size="14pt"
        style:font-size-asian="14pt"
        style:font-size-complex="14pt"/>
    </style:style>
    
    <style:style
      style:name="Text-Full-Width"
      style:family="paragraph"
      style:parent-style-name="Standard">
      <style:paragraph-properties
        fo:text-align="justify"
        fo:margin-top="0.15cm"
        style:justify-single-word="false"/>
      <style:text-properties
        style:font-name="Garamand Classic"
        fo:font-size="10pt"
        style:font-size-asian="10pt"
        style:font-size-complex="10pt"/>
    </style:style>
    
    <!-- the fo:font-style=italic is a microsoft compatibility artifact -->
    <style:style
      style:name="Heading-Small"
      style:family="paragraph"
      style:parent-style-name="Standard">
      <style:paragraph-properties
        fo:text-align="start"
        fo:margin-top="0.2cm"
        style:justify-single-word="false"/>
      <style:text-properties
        style:font-name="Top Hat"
        fo:font-size="14pt"
        fo:font-style="italic"
        style:font-size-asian="14pt"
        style:font-size-complex="14pt"/>
    </style:style>
    
    <style:style style:name="Text-Full-Indent" style:family="paragraph"
      style:parent-style-name="Standard">
      <style:paragraph-properties
        fo:margin-left="1.45cm"
        fo:margin-right="0cm"
        fo:text-align="justify"
        style:justify-single-word="false"
        fo:text-indent="0cm"
        style:auto-text-indent="false"/>
      <style:text-properties
        style:font-name="Garamand Classic"
        fo:font-size="10pt"
        style:font-size-asian="10pt"
        style:font-size-complex="10pt"/>
    </style:style>
    
    <style:style style:name="Work-Item"
      style:family="paragraph"
      style:parent-style-name="Standard">
      <style:paragraph-properties
        fo:margin-left="1.45cm"
        fo:margin-right="0cm"
        fo:margin-top="0.15cm"
        fo:text-align="justify"
        fo:text-indent="-1.45cm"
        style:justify-single-word="false"
        style:auto-text-indent="false">
        <style:tab-stops/>
      </style:paragraph-properties>
      <style:text-properties
        style:font-name="Garamand Classic"
        fo:font-size="10pt"
        style:font-size-asian="10pt"
        style:font-size-complex="10pt"/>
    </style:style>
    
    <style:style
      style:name="Gazette-inline"
      style:family="text">
      <style:text-properties
        style:font-name="Gazette"/>
    </style:style>

    <style:style
      style:name="Calendar-Item"
      style:family="paragraph"
      style:parent-style-name="Standard"
      style:class="index"
      style:master-page-name="">
      <style:paragraph-properties
        text:number-lines="false"
        text:line-number="0"
        fo:margin-left="0cm"
        fo:margin-right="0cm"
        fo:margin-top="0.05cm"
        fo:text-indent="0cm"
        fo:keep-together="always"
        fo:background-color="transparent"
        style:auto-text-indent="false"
        style:shadow="none">
        <style:tab-stops>
          <style:tab-stop
            style:position="1.45cm"/>
          <style:tab-stop
            style:position="17cm"
            style:type="right"
            style:leader-style="dotted"
            style:leader-text="."/>
        </style:tab-stops>
      </style:paragraph-properties>
      <style:text-properties
        style:font-name="Garamand Classic"
        fo:font-size="10pt"/>
    </style:style>

    <style:style
      style:name="gloat"
      style:family="paragraph"
      style:parent-style-name="Standard">
      <style:paragraph-properties
        fo:margin-left="2cm"
        fo:margin-right="2cm"
        fo:margin-top="0.071cm"
        fo:margin-bottom="0cm"
        fo:text-align="center"
        style:justify-single-word="false"
        fo:text-indent="0cm"
        style:auto-text-indent="false"
        fo:background-color="transparent"
        style:shadow="none"
        text:number-lines="false"
        text:line-number="0">
        <style:tab-stops>
          <style:tab-stop
            style:position="1.45cm"/>
          <style:tab-stop
            style:position="17cm"
            style:type="right"
            style:leader-style="dotted"
            style:leader-text="."/>
        </style:tab-stops>
        <style:background-image/>
      </style:paragraph-properties>
      <style:text-properties
        style:font-name="Papyrus"
        fo:font-size="8pt"
        style:font-size-asian="8pt"
        style:font-size-complex="8pt"/>
    </style:style>

  </xsl:param>
  

  <xsl:template match="/">
    <office:document-content
      xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
      xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0"
      xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0"
      xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0"
      xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0"
      xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"
      xmlns:xlink="http://www.w3.org/1999/xlink"
      xmlns:dc="http://purl.org/dc/elements/1.1/"
      xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0"
      xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0"
      xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0"
      xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0"
      xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0"
      xmlns:math="http://www.w3.org/1998/Math/MathML"
      xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0"
      xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0"
      xmlns:ooo="http://openoffice.org/2004/office"
      xmlns:ooow="http://openoffice.org/2004/writer"
      xmlns:oooc="http://openoffice.org/2004/calc"
      xmlns:dom="http://www.w3.org/2001/xml-events"
      xmlns:xforms="http://www.w3.org/2002/xforms"
      xmlns:xsd="http://www.w3.org/2001/XMLSchema"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      office:version="1.0">
      <office:scripts/>
      
      <office:font-face-decls>
        <xsl:copy-of select="$fonts/microsoft/*"/>
      </office:font-face-decls>
      
      <office:automatic-styles>
        <xsl:copy-of select="$styles/*"/>
      </office:automatic-styles>
      
      <office:body>
        <office:text>
          
          <xsl:call-template name="contact-info"/>
          
          <xsl:call-template name="simple-section">
            <xsl:with-param name="heading">Objective</xsl:with-param>
            <xsl:with-param name="body" select="/resume/objective"/>
          </xsl:call-template>
          
          <xsl:call-template name="simple-section">
            <xsl:with-param name="heading">Summary</xsl:with-param>
            <xsl:with-param name="body" select="/resume/summary"/>
          </xsl:call-template>
          
          <xsl:call-template name="accomplishments"/>
          
          <xsl:call-template name="calendar-section">
            <xsl:with-param name="heading">Work Experience</xsl:with-param>
            <xsl:with-param name="body" select="/resume/experience"/>
          </xsl:call-template>
          
          <xsl:call-template name="calendar-section">
            <xsl:with-param name="heading">Education</xsl:with-param>
            <xsl:with-param name="body" select="/resume/education"/>
          </xsl:call-template>
          
          <text:p text:style-name="gloat">
            This document was generated using  XML &amp; XSLT. The
            resulting OASIS OpenDocument  was then processed using
            OpenOffice.org Writer software to produce a Microsoft Word
            document. The source code can be downloaded from
            http://cyber-rush.org/drr/CV
          </text:p>
        </office:text>
      </office:body>
    </office:document-content>
  </xsl:template>


  <xsl:template name="labelled">
    <xsl:param name="label">label:</xsl:param>
    <xsl:param name="text">text</xsl:param>
    <text:p text:style-name="Main-Address">
      <text:span text:style-name="Gazette-inline">
        <xsl:value-of select="$label"/>
      </text:span>
      <xsl:value-of select="$text"/>
    </text:p>
  </xsl:template>


  <xsl:template name="heading">
    <xsl:param name="text">heading</xsl:param>
    <text:p text:style-name="Heading-Big">
      <xsl:copy-of select="$text"/>
    </text:p>
  </xsl:template>


  <xsl:template name="sub-heading">
    <xsl:param name="text">heading</xsl:param>
    <text:p text:style-name="Heading-Small">
      <xsl:copy-of select="$text"/>
    </text:p>
  </xsl:template>


  <xsl:template name="contact-info">
    <text:p text:style-name="Main-Name">
      <xsl:value-of select="/resume/who/name"/>
    </text:p>

    <xsl:for-each select="/resume/who/address">
      <text:p text:style-name="Main-Address">
        <xsl:value-of select="."/>
      </text:p>
    </xsl:for-each>

    <xsl:call-template name="labelled">
      <xsl:with-param name="label">email:</xsl:with-param>
      <xsl:with-param name="text">
        <xsl:value-of select="/resume/who/email"/>
      </xsl:with-param>
    </xsl:call-template>

    <xsl:call-template name="labelled">
      <xsl:with-param name="label">mobile:</xsl:with-param>
      <xsl:with-param name="text">
        <xsl:value-of select="/resume/who/mobile"/>
      </xsl:with-param>
    </xsl:call-template>

    <xsl:call-template name="labelled">
      <xsl:with-param name="label">phone:</xsl:with-param>
      <xsl:with-param name="text">
        <xsl:value-of select="/resume/who/phone"/>
      </xsl:with-param>
    </xsl:call-template>   
  </xsl:template>


  <xsl:template name="simple-section">
    <xsl:param name="heading">heading</xsl:param>
    <xsl:param name="body">body</xsl:param>
    <xsl:call-template name="heading">
      <xsl:with-param name="text">
        <xsl:value-of select="$heading"/>
      </xsl:with-param>
    </xsl:call-template>
    <text:p text:style-name="Text-Full-Width">
      <xsl:value-of select="$body"/>
    </text:p>
  </xsl:template>


  <xsl:template name="acc-section">
    <xsl:param name="heading">heading</xsl:param>
    <xsl:call-template name="sub-heading">
      <xsl:with-param name="text"><xsl:value-of select="$heading"/></xsl:with-param>
    </xsl:call-template>
    <xsl:for-each
      select="/resume/accomplishments/section[@heading=$heading]/*">
      <text:p text:style-name="Work-Item">
        <text:span text:style-name="Gazette-inline">
          [<xsl:value-of select="@at"/>]
        </text:span>
        <text:tab/><xsl:value-of select="normalize-space(.)"/>
      </text:p>
    </xsl:for-each>
  </xsl:template>


  <xsl:template name="accomplishments">
    <xsl:call-template name="heading">
      <xsl:with-param name="text">Accomplishments</xsl:with-param>
    </xsl:call-template>

    <xsl:call-template name="acc-section">
      <xsl:with-param name="heading">Leadership &amp; Management</xsl:with-param>
    </xsl:call-template>

    <xsl:call-template name="acc-section">
      <xsl:with-param name="heading">Software Development</xsl:with-param>
    </xsl:call-template>

    <xsl:call-template name="acc-section">
      <xsl:with-param name="heading">Applied Research</xsl:with-param>
    </xsl:call-template>
  </xsl:template>


  <xsl:template name="calendar-section">
    <xsl:param name="heading">heading</xsl:param>
    <xsl:param name="body">body</xsl:param>
    <xsl:call-template name="heading">
      <xsl:with-param name="text">
        <xsl:value-of select="$heading"/>
      </xsl:with-param>
    </xsl:call-template>
    <xsl:for-each select="$body/activity">
      <text:p text:style-name="Calendar-Item">
        <text:span text:style-name="Gazette-inline">
          <xsl:choose>
            <xsl:when test="@id">
              [<xsl:value-of select="@id"/>]
            </xsl:when>
            <xsl:when test="@at">
              (<xsl:value-of select="@at"/>)
            </xsl:when>
            <xsl:otherwise>*</xsl:otherwise>
          </xsl:choose>
        </text:span>
        <text:tab/>
        <xsl:value-of select="@desc"/>
        <text:tab/>
        <xsl:for-each select="*">
          [<xsl:value-of select="."/>]
        </xsl:for-each>
      </text:p>      
    </xsl:for-each>
  </xsl:template>
  
</xsl:stylesheet>
